命令

Docker 命令 #

docker ps #

docker ps vs docker container ls #

Management Commands vs Commands

Docker 1.13+ introduced grouped commands to help organize a bunch of Docker commands. Both commands do the same thing.

For example docker container ls is the new way to do docker ps.

Sure it’s more typing, but it’s a lot more clear on what it does. Likewise, now you can run docker image ls, docker network ls or docker volume ls. There’s consistency across all of these commands.

参考:


docker attach vs docker exec #

$ sudo docker attach 665b4a1e17b6 #by ID
or
$ sudo docker attach loving_heisenberg #by Name
$ root@665b4a1e17b6:/#

$ sudo docker exec -i -t 665b4a1e17b6 /bin/bash #by ID
or
$ sudo docker exec -i -t loving_heisenberg /bin/bash #by Name
$ root@665b4a1e17b6:/#
  • docker attach isn’t for running an extra thing in a container, it’s for attaching to the running process.
    • attach 只有一个实例
  • docker exec is specifically for running new things in a already started container, be it a shell or some other process.
    • exec 可以启动多个

参考:


本文访问量

本站总访问量

本站总访客数