Docker和宿主Host的关系如上图所示。
查看docker
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
51bf8220a09f redis:5.0.3 "docker-entrypoint..." 4 months ago Exited (139) 7 weeks ago sun_redis
c79ea0e16348 idoop/zentao "docker-entrypoint" 5 months ago Up 3 months (healthy) 0.0.0.0:10080->80/tcp, 0.0.0.0:13306->3306/tcp zentao
abae3dd5c421 minio/minio "/usr/bin/docker-e..." 6 months ago Up 3 months 0.0.0.0:9000->9000/tcp sun_minio
58b35062d215 mysql:5.7 "docker-entrypoint..." 6 months ago Up 3 months 0.0.0.0:3306->3306/tcp, 33060/tcp sun_mysql
进入docker
docker exec -it 容器id /bin/bash
# docker exec -it c79ea0e16348 /bin/bash
root@c79ea0e16348:/# ll
total 72
drwxr-xr-x 1 root root 4096 Nov 23 03:34 ./
drwxr-xr-x 1 root root 4096 Nov 23 03:34 ../
-rwxr-xr-x 1 root root 0 Nov 23 03:34 .dockerenv*
drwxr-xr-x 2 root root 4096 May 26 2020 bin/
drwxr-xr-x 2 root root 4096 Apr 24 2018 boot/
drwxr-xr-x 5 root root 340 Jan 27 01:47 dev/
drwxr-xr-x 1 root root 4096 Nov 23 03:34 etc/
drwxr-xr-x 2 root root 4096 Apr 24 2018 home/
drwxr-xr-x 1 root root 4096 May 23 2017 lib/
drwxr-xr-x 2 root root 4096 May 26 2020 lib64/
drwxr-xr-x 2 root root 4096 May 26 2020 media/
drwxr-xr-x 2 root root 4096 May 26 2020 mnt/
drwxr-xr-x 1 root root 4096 Nov 23 03:34 opt/
dr-xr-xr-x 144 root root 0 Jan 27 01:47 proc/
drwx------ 2 root root 4096 May 26 2020 root/
drwxr-xr-x 1 root root 4096 Nov 23 03:34 run/
drwxr-xr-x 1 root root 4096 Jun 17 2020 sbin/
drwxr-xr-x 2 root root 4096 May 26 2020 srv/
dr-xr-xr-x 13 root root 0 Nov 21 06:46 sys/
drwxrwxrwt 1 root root 4096 May 12 07:26 tmp/
drwxr-xr-x 1 root root 4096 May 26 2020 usr/
drwxr-xr-x 1 root root 4096 May 26 2020 var/
出去
# exit
exit
导出文件
docker cp 容器id:容器文件路径 宿主目录路径
docker cp c79ea0e16348:/opt/test.txt /opt
停止一个容器
# docker stop c79ea0e16348
c79ea0e16348
开启一个容器
# docker start c79ea0e16348
c79ea0e16348
停止后,容器依然存在,只是没有运行罢了,类似于进程杀死。