安装docker

https://jumpserver.readthedocs.io/zh/master/install/docker_install/

yum list docker

提示

docker.x86_64                                              2:1.13.1-162.git64e9980.el7.centos

更新yum源

mkdir ./bak
cp -r /etc/yum.repos.d/* ./bak
rm -rf /etc/yum.repos.d/*
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce

提示:Updated:

docker-ce.x86_64 3:19.03.12-3.el7 

配置镜像加速器

https://cr.console.aliyun.com/
systemctl start docker
vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://a02qujam.mirror.aliyuncs.com"]
}
systemctl restart docker

生成随机key

vim ./key.sh
if [ ! "$SECRET_KEY" ]; then
  SECRET_KEY=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 50`;
  echo "SECRET_KEY=$SECRET_KEY" >> ~/.bashrc;
  echo $SECRET_KEY;
else
  echo $SECRET_KEY;
fi  
if [ ! "$BOOTSTRAP_TOKEN" ]; then
  BOOTSTRAP_TOKEN=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c 16`;
  echo "BOOTSTRAP_TOKEN=$BOOTSTRAP_TOKEN" >> ~/.bashrc;
  echo $BOOTSTRAP_TOKEN;
else
  echo $BOOTSTRAP_TOKEN;
fi
echo $SECRET_KEY
WNLwvwFI65XY7YXOG57bIz5qRsyNAbS2FPKlKwNQ1ViXiXSLxl
$BOOTSTRAP_TOKEN
N3mh5Bk5jZukvf9z

外部数据库版

创建宿主机文件

mkdir -pv /opt/mysql
mkdir -pv /opt/jumpserver

安装数据库并配置

yum -y install mariadb-server
create database jumpserver default charset 'utf8' collate 'utf8_bin';
grant all on jumpserver.* to 'jumpserver'@'%' identified by 'silence2t';
flush privileges;

测试客户端登录数据库

yum install -y mysql
mysql -ujumpserver -psilence2t -h 172.24.77.242
show databases;
| Database           |
+--------------------+
| information_schema |
| jumpserver         |
| test               |
+--------------------+
3 rows in set (0.00 sec)

Redis安装并配置

yum -y install redis
vim /etc/redis.conf +61
    bind 0.0.0.0
    requirepass silence2t
redis-cli -h 172.24.77.242
AUTH silence2t
    OK
docker run --name jump_srv -d \
-v /opt/mysql:/var/lib/mysql \
-v /opt/jumpserver:/opt/jumpserver/data/media \
-p 80:80 \
-p 2222:2222 \
-e SECRET_KEY=WNLwvwFI65XY7YXOG57bIz5qRsyNAbS2FPKlKwNQ1ViXiXSLxl \
-e BOOTSTARP_TOKEN=N3mh5Bk5jZukvf9z \
-e DB_HOST=172.24.77.242 \
-e DB_PORT=3306 \
-e DB_USER=jumpserver \
-e DB_PASSWORD=silence2t \
-e DB_NAME=jumpserver \
-e REDIS_HOST=172.24.77.242 \
-e REDIS_PORT=6379 \
-e REDIS_PASSWORD=silence2t \
jumpserver/jms_all:1.4.8

查看是否启动成功

docker ps -a
docker logs -f a65b20f7977c

提示:

gunicorn is running: 54
celery is running: 74
beat is running: 76
guacd[98]: INFO:    Guacamole proxy daemon (guacd) version 0.9.14 started
Starting guacd: SUCCESS
Tomcat started.
Use eventlet dispatch
Start coco process
Use eventlet dispatch
Start coco process
Use eventlet dispatch
Start coco process
Jumpserver ALL 1.4.8
官网 http://www.jumpserver.org
文档 http://docs.jumpserver.org
有问题请参考 http://docs.jumpserver.org/zh/docs/faq.html
进入容器命令 docker exec -it jms_all /bin/bash

测试访问:

http://172.24.77.242
admin admin

使用docker安装部署jumpserver跳板机_第1张图片

登录后台

docker exec -it 15dfc617558d /bin/sh