I used it
docker-composeTo start the container,
docker ps -alLists stopped containers,
docker container lsThe running containers are listed, but the containers in the “running” and “exiting” states are directly run to start, using the
docker ps -alAs you can see, I feel confused about these two commands.
I looked at the document and said
docker ps -alUsed to list containers,
docker containerIs there any difference between the two commands used to manage containers? Why can’t a single command list all containers?
Ask passing bosses to explain
The difference between docker ps and dockercontainers ls
Docker 1.13+ introduces grouping commands to help organize a stack of Docker commands. Both orders do the same thing.
If you run docker help and use Docker 1.13+ (including v17.03+), you will see “Administrative Commands” and “Commands” in the help text.
Management Commands: ... container Manage containers image Manage images ... Commands: ... ps List containers run Run a command in a new container ...
The full output is much longer, if you look at the entire command list, there are about 40 of them. It is difficult to view this list because these commands are associated with containers, images, networks, volumes, etc.
Docker realized that this is not sustainable in the long run, so they added “management commands”, which help classify all commands and make the commands themselves more consistent.
For example, dockercontainers ls is a new method docker ps. Of course, this requires more typing, but its function is clearer. Similarly, you can now run docker image ls, dockernetworksor dockervolumes. All these commands are consistent.
Both versions of the command do the same thing. I think in the long run, non-group commands (such as docker run) will be discarded and the use of docker container run will not be approved. There is no sign that this will happen soon, but if you use Docker 1.13+, you should try to use the updated syntax. It is more descriptive and consistent.