docker命令详解
1 # docker --help 2 Usage: docker [OPTIONS] COMMAND [arg...] 3 docker daemon [ --help | ... ] 4 docker [ -h | --help | -v | --version ] 5 6 A self-sufficient runtime for containers. 7 8 Options: 9 10 --config=~/.docker Location of client config files 11 -D, --debug=false Enable debug mode 12 -H, --host=[] Daemon socket(s) to connect to 13 -h, --help=false Print usage 14 -l, --log-level=info Set the logging level 15 --tls=false Use TLS; implied by --tlsverify 16 --tlscacert=~/.docker/ca.pem Trust certs signed only by this CA 17 --tlscert=~/.docker/cert.pem Path to TLS certificate file 18 --tlskey=~/.docker/key.pem Path to TLS key file 19 --tlsverify=false Use TLS and verify the remote 20 -v, --version=false Print version information and quit 21 22 Commands: 23 attach Attach to a running container 24 --将终端依附到容器上 25 1> 运行一个交互型容器 26 [root@localhost ~]# docker run -i -t centos /bin/bash 27 [root@f0a02b473067 /]# 28 2> 在另一个窗口上查看该容器的状态 29 [root@localhost ~]# docker ps -a 30 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 31 d4a75f165ce6 centos "/bin/bash" 5 seconds ago Up 5 seconds cranky_mahavira 32 3> 退出第一步中运行的容器 33 [root@d4a75f165ce6 /]# exit 34 exit 35 4> 查看该容器的状态 36 [root@localhost ~]# docker ps -a 37 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 38 d4a75f165ce6 centos "/bin/bash" 2 minutes ago Exited (0) 23 seconds ago cranky_mahavira 39 可见此时容器的状态是Exited,那么,如何再次运行这个容器呢?可以使用docker start命令 40 5> 再次运行该容器 41 [root@localhost ~]# docker start cranky_mahavira 42 cranky_mahavira 43 6> 再次查看该容器的状态 44 [root@localhost ~]# docker ps -a 45 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 46 d4a75f165ce6 centos "/bin/bash" 6 minutes ago Up 29 seconds cranky_mahavira 47 因为该容器是交互型的,但此刻我们发现没有具体的终端可以与之交互,这时可使用attach命令。 48 7> 通过attach命令进行交互 49 [root@localhost ~]# docker attach cranky_mahavira 50 [root@d4a75f16

最低0.47元/天 解锁文章
522

被折叠的 条评论
为什么被折叠?



