查询正在运行的容器 :docker ps
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6c06fbac244a mysql "docker-entrypoint.s…" 45 hours ago Up 5 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp haige
查询已运行的容器(包含过去和现在):docker ps -a
$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 75b437c481c5 mysql "docker-entrypoint.s…" About a minute ago Exited (1) About a minute ago pedantic_blackburn 6c06fbac244a mysql "docker-entrypoint.s…" 43 hours ago Exited (255) 11 minutes ago 0.0.0.0:3306->3306/tcp, 33060/tcp haige 2b454497bcff mysql "docker-entrypoint.s…" 43 hours ago Exited (0) 43 hours ago mysql b75bacd45023 nginx "nginx -g 'daemon of…" 11 days ago Exited (255) 9 days ago 0.0.0.0:8081->80/tcp runoob-nginx-test 3e1cd3976d9b zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (255) 3 weeks ago 2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:2182->2181/tcp zk2 248d0188db61 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (255) 3 weeks ago 2888/tcp, 3888/tcp, 0.0.0.0:2181->2181/tcp, 8080/tcp zk1 a4de0d6fc352 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (0) 3 weeks ago elastic_hawking 3b2db1b7d689 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (0) 3 weeks ago brave_mahavira 2e0e0e064b08 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (0) 3 weeks ago nostalgic_wozniak e4a1fe409e69 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (0) 3 weeks ago youthful_hermann dde6a613eb4d zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (126) 3 weeks ago quirky_bardeen 073aaf991376 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (2) 3 weeks ago pedantic_kapitsa 4819fd6aa6c3 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (2) 3 weeks ago distracted_dirac 5877ac92dbb2 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (130) 3 weeks ago silly_jackson d5eb1a199ea8 zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (130) 3 weeks ago frosty_perlman 586603309abd zookeeper "/docker-entrypoint.…" 3 weeks ago Exited (130) 3 weeks ago naughty_villani
重启某服务:docker restart 6c06fbac244a84f1f99b06eb6079b143ef2449df2f246af452e6c2fd3a0ea7b8 (注意:红色的为CONTAINER ID ,来自 docker ps中)
$ docker restart 6c06fbac244a84f1f99b06eb6079b143ef2449df2f246af452e6c2fd3a0ea7b8