首先查看容器名称
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
beef5f3420e7 jumpserver/nginx:alpine2 "sh -c 'crond -b -d …" 4 weeks ago Up 36 minutes (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp jms_nginx
f7ff9cf68539 jumpserver/luna:v2.7.0 "/docker-entrypoint.…" 4 weeks ago Up 36 minutes (healthy) 80/tcp jms_luna
6a8ff0438403 jumpserver/lina:v2.7.0 "/docker-entrypoint.…" 4 weeks ago Up 36 minutes (healthy) 80/tcp jms_lina
b55210e92336 jumpserver/guacamole:v2.7.0 "/init" 4 weeks ago Up 36 minutes (healthy) 8080/tcp jms_guacamole
9bbc52eea192 jumpserver/koko:v2.7.0 "./entrypoint.sh" 4 weeks ago Up 36 minutes (healthy) 0.0.0.0:2222->2222/tcp, 5000/tcp jms_koko
6e7ade548b2c jumpserver/core:v2.7.0 "./entrypoint.sh sta…" 4 weeks ago Up 36 minutes (healthy) 8070/tcp, 8080/tcp jms_celery
4c0f617bed96 jumpserver/core:v2.7.0 "./entrypoint.sh sta…" 4 weeks ago Up 36 minutes (healthy) 8070/tcp, 8080/tcp jms_core
c409697af4ee jumpserver/mysql:5 "docker-entrypoint.s…" 6 months ago Up 36 minutes (healthy) 3306/tcp, 33060/tcp jms_mysql
6d16657cd0e1 jumpserver/redis:6-alpine "docker-entrypoint.s…" 6 months ago Up 36 minutes (healthy) 6379/tcp jms_redis
进入并新建一个mysql容器控制台
docker exec -it jms_mysql /bin/bash
进行数据库表备份,然后复制备份文件到本地
[root@localhost opt]# docker exec -it jms_mysql /bin/bash
[root@c409697af4ee:/# mysqldump -h$DB_HOST -P$DB_PORT -u$DB_USER -p$DB_PASSWORD $DB_NAME > /opt/jumpserver.sql
[root@c409697af4ee:/# exit
[root@localhost opt]# docker cp jms_mysql:/opt/jumpserver.sql /opt/