Docker方式安装Jumpserver

之前有自己手动封装过Jumpserver的Docker镜像,既然官方发布的有Docker那就使用官方的。不过官方的是DockerAllinone模式,推荐使用外置DB及Reids。所以这里就再弄一个用。如官方所述需要注意Mysql的编码问题,另外还有一个关于Docker的volume小瑕疵,其他的就没有什么问题了。官方链接放在最后需要的自取,另外以下代码在我的【github】上都有。

开箱即用

准备工作

  • my.cnf (指定Mysql的启动配置)
  • docker-compose.yml (编排配置)

Mysql配置文件

1
2
3
4
[mysqld]
character-set-server = utf8
collation-server = utf8_unicode_ci
skip-character-set-client-handshake

使用的docker-compose如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
version: '3'
services:
db:
image: mysql:5.7.23
restart: always
container_name: "mysql_jms"
environment:
MYSQL_ROOT_PASSWORD: 123456
MYSQL_DATABASE: jumpserver
MYSQL_USER: jumpserver
MYSQL_PASSWORD: 123456
ports:
- 3306:3306
volumes:
- /data/jumpserver-data/mysql:/var/lib/mysql
- /data/docker-app/jms/my.cnf:/etc/mysql/conf.d/custom.cnf
networks:
- "jumpservernet"
redis:
image: redis:3
container_name: "redis_jms"
restart: always
ports:
- 6379:6379
volumes:
- /data/jumpserver-data/redis:/data
networks:
- "jumpservernet"
jumpserver:
image: wojiushixiaobai/jumpserver:1.4.3
container_name: "jms_v1.4.3"
restart: always
depends_on:
- db
- redis
environment:
DB_ENGINE: mysql
DB_HOST: db
DB_PORT: 3306
DB_USER: jumpserver
DB_PASSWORD: 123456
DB_NAME: jumpserver
REDIS_HOST: redis
REDIS_PORT: 6379
ports:
- 8080:80
- 2222:2222
volumes:
- /data/jumpserver-data/jms_data/jms:/opt/jumpserver/data
- /data/jumpserver-data/jms_data/coco_keys:/opt/coco/keys
- /data/jumpserver-data/jms_data/guacamole:/config/guacamole/keys
- /data/jumpserver-data/jms_data/mysql:/var/lib/mysql
networks:
- "jumpservernet"
networks:
jumpservernet:
driver: bridge

故障排查

  • mysql问题(确认mysql编码正确)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    mysql> show variables like 'character%';
    +--------------------------+----------------------------+
    | Variable_name | Value |
    +--------------------------+----------------------------+
    | character_set_client | utf8 |
    | character_set_connection | utf8 |
    | character_set_database | utf8 |
    | character_set_filesystem | binary |
    | character_set_results | utf8 |
    | character_set_server | utf8 |
    | character_set_system | utf8 |
    | character_sets_dir | /usr/share/mysql/charsets/ |
    +--------------------------+----------------------------+
    8 rows in set (0.01 sec)
  • Docker的volume问题
    如果不将docker定义的volume挂载出来,测试阶段会多出很多无用的volume,按照上面的配置就没问题,下面贴一个可以方便删除指定volume的命令

    1
    docker volume ls | grep local |awk '{print $2}' |xargs docker volume rm

参考链接