容器的基本操作

操作 命令(全) 命令(简)
容器的创建 docker container run < image name> docker run < image name>
容器的列出(up) docker container ls docker ps
容器的列出(up和exit) docker container ls -a docker ps -a
容器的停止 docker container stop docker stop
容器的删除 docker container rm docker rm

Demo

  1. $ docker container run nginx
  2. $ docker ps
  3. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  4. 343fd4031609 nginx "/docker-entrypoint.…" 6 seconds ago Up 5 seconds 80/tcp xenodochial_clarke
  5. $ docker container ls
  6. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  7. 343fd4031609 nginx "/docker-entrypoint.…" 14 seconds ago Up 13 seconds 80/tcp xenodochial_clarke
  8. $ docker container stop 34
  9. 34
  10. $ docker container ls -a
  11. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  12. 343fd4031609 nginx "/docker-entrypoint.…" 29 seconds ago Exited (0) 5 seconds ago xenodochial_clarke
  13. d9095daa8bcf nginx "/docker-entrypoint.…" 28 minutes ago Exited (0) 28 minutes ago suspicious_shamir
  14. $ docker container rm 34
  15. 34
  16. $ docker container ls -a
  17. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  18. d9095daa8bcf nginx "/docker-entrypoint.…" 28 minutes ago Exited (0) 28 minutes ago suspicious_shamir
  19. $