Public | Automated Build

Last pushed: 6 months ago
Short Description
jumpserver-3.0
Full Description

源码github:https://github.com/njqaaa/jumpserver

以下所有操作都在宿主机上操作

使用overlay网络,使容器可以解析容器name转换为ip

docker swarm init
docker network create -d overlay --attachable jumpserver --subnet=192.168.100.0/24
export DB_HOST=jumpserver-mysql
export DB_USER=root
export DB_PASSWORD=mypassword
export DB_PORT=3306
export DB_NAME=jumpserver_db
export SITE_URL=http://jumpserver.xxx.com
export EMAIL_PORT=587
export EMAIL_HOST=smtp.xxx.com
export EMAIL_HOST_USER=jumpserver@xxx.com
export EMAIL_HOST_PASSWORD=******
export SERVER_NAME=jumpserver

创建数据库,需要等待mysql启动完成(预计10秒)

docker run -d --restart=always --name $DB_HOST -e MYSQL_ROOT_PASSWORD=$DB_PASSWORD --network jumpserver mysql:5.7
docker exec -it $DB_HOST mysql -u$DB_USER -p$DB_PASSWORD -e 'CREATE DATABASE '$DB_NAME' DEFAULT CHARACTER SET utf8 ';

容器自定义配置,使用环境变量方式

echo -e "DB_HOST=$DB_HOST\nDB_USER=$DB_USER\nDB_PASSWORD=$DB_PASSWORD\nDB_NAME=$DB_NAME\nSITE_URL=$SITE_URL\nEMAIL_PORT=$EMAIL_PORT\nEMAIL_HOST=$EMAIL_HOST\nEMAIL_HOST_USER=$EMAIL_HOST_USER\nEMAIL_HOST_PASSWORD=$EMAIL_HOST_PASSWORD" > /tmp/envinfo

envinfo信息如下:

cat envinfo
DB_HOST=jumpserver-mysql
DB_USER=root
DB_PASSWORD=mypassword
DB_NAME=jumpserver_db
SITE_URL=http://jumpserver.xxx.com
EMAIL_PORT=587
EMAIL_HOST=smtp.xxx.com
EMAIL_HOST_USER=jumpserver@xxx.com
EMAIL_HOST_PASSWORD=******

envinfo参数list如下:

EMAIL_HOST = os.environ.get('EMAIL_HOST') or 'smtp.qq.com'
EMAIL_PORT = int(os.environ.get('EMAIL_PORT', 465))
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER') or 'admin'
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD') or 'somepasswrd'
EMAIL_SUBJECT_PREFIX = os.environ.get('EMAIL_SUBJECT_PREFIX') or '[Jumpserver] '
LOG_DIR = os.path.join(BASE_DIR, 'logs')
SSH_KEY_DIR = os.path.join(BASE_DIR, 'keys/role_keys')
URL = os.environ.get('SITE_URL') or 'http://localhost'
DB_HOST = os.environ.get('DB_HOST') or '127.0.0.1'
DB_PORT = os.environ.get('DB_PORT') or '3306'
DB_USER = os.environ.get('DB_USER') or 'root'
DB_PASSWORD = os.environ.get('DB_PASSWORD') or 'root'
DB_DATABASE = os.environ.get('DB_NAME') or 'jumpserver_db'

启动服务,映射到本地80/22端口

docker run -d --restart=always --name $SERVER_NAME -p 80:80 -p 88:22 --env-file=/tmp/envinfo -v `pwd`/data:/data --network jumpserver njqaaa/jumpserver-3.0

初始化db

docker exec -it $SERVER_NAME python /root/jumpserver/manage.py syncdb
docker exec -it $DB_HOST mysql -u$DB_USER -p$DB_PASSWORD -e 'CREATE DATABASE '$DB_NAME' DEFAULT CHARACTER SET utf8 ';
docker exec -it $DB_HOST mysql -u$DB_USER -p$DB_PASSWORD -A $DB_NAME -e 'update juser_user set role = "SU" '
docker exec -it $SERVER_NAME python manage.py crontab add
```

验证

docker exec -it $SERVER_NAME curl -i 127.0.0.1

账号密码

admin admin

Docker Pull Command
Owner
njqaaa
Source Repository