docker run进去容器,exit退出,容器停止
run运行进去容器,ctrl+p+q退出,容器不停止。如果加了-d,就守护式启动容器,exit的命令,容器是不会停止的
exec进的容器,exit或者是ctrl+d,容器不会停止.只是退出
[root@zk117 ~]# docker run -it --name="ub1" ubuntu bash
root@03633ca3e9ed:/# exit
exit
[root@zk117 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@zk117 ~]#
[root@zk117 ~]# docker run -it -d --name="ub2" ubuntu bash
b54e73897260d028cce5e1f4a715b4e22f74690bcae1e168f36494e6fb6c7d09
[root@zk117 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b54e73897260 ubuntu "bash" 7 seconds ago Up 6 seconds ub2
[root@zk117 ~]# docker exec -it ub2
"docker exec" requires at least 2 arguments.
See 'docker exec --help'.
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Execute a command in a running container
[root@zk117 ~]# docker exec -it ub2 bash
root@b54e73897260:/# exit
exit
[root@zk117 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b54e73897260 ubuntu "bash" 5 minutes ago Up 5 minutes ub2