Is there a difference between “docker ps” and “docker container ls”?

前端 未结 2 1121
天涯浪人
天涯浪人 2020-12-08 13:18

The documentation of docker ps and docker container ls both says \"List containers\", but does not mention the other command. Is there a difference between those two command

2条回答
  •  广开言路
    2020-12-08 13:53

    There is no difference between docker ps and docker container ls. The new command structure (docker container ) was added in Docker 1.13 to provider a more structured user experience when using the command line.

    To my knowledge, there has not yet been any official announcement to drop support for the old-style commands (like docker ps and others), although it might be reasonable to assume this might happen at some point in the future.

    This is described in a blog post accompanying the release of Docker 1.13:

    Docker has grown many features over the past couple years and the Docker CLI now has a lot of commands (40 at the time of writing). Some, like build or run are used a lot, some are more obscure, like pause or history. The many top-level commands clutters help pages and makes tab-completion harder.

    In Docker 1.13, we regrouped every command to sit under the logical object it’s interacting with. For example list and startof containers are now subcommands of docker container and history is a subcommand of docker image.

    docker container list
    docker container start
    docker image history
    

    These changes let us clean up the Docker CLI syntax, improve help text and make Docker simpler to use. The old command syntax is still supported, but we encourage everybody to adopt the new syntax.

提交回复
热议问题