docker 容器 命令行
The Docker Desktop application is awesome to work with containers locally via a graphical interface.
Docker Desktop应用程序很棒,可以通过图形界面在本地使用容器。
You are not required to use it. You can use the CLI commands.
您不需要使用它。 您可以使用CLI命令。
The docker ps
command lists the currently running containers:
docker ps
命令列出了当前正在运行的容器:
This is the same as running
docker container ls
.这与运行
docker container ls
相同。
In this case, container with name node-app
and ID 739037a911e0
generated from the image examplenode
, created 4 minutes ago
, is up since 4 minutes, and the port 80 of the host machine is mapped to the container port 3000 using the TCP protocol.
在这种情况下,用名容器node-app
和ID 739037a911e0
从图像生成examplenode
,在4 minutes ago
,是向上自4分钟,和主机的端口80使用TCP协议映射到容器端口3000。
When you know the contained ID, you can stop the container by running
当您知道所包含的ID时,可以通过运行来停止容器
docker container stop <ID>
Once a container is stopped, you can see it using docker container ls -a
:
容器停止后,您可以使用docker container ls -a
看到它:
And you can remove it using docker container rm
:
您可以使用docker container rm
删除它:
docker container rm <ID>
You can inspect all the details about a container running docker inspect
:
您可以检查有关运行docker inspect
的容器的所有详细信息:
Another useful CLI command is docker info
which gives you lots of information about the current state of your Docker installation, including the number of containers and images.
另一个有用的CLI命令是docker info
,它为您提供有关Docker安装当前状态的大量信息,包括容器和映像的数量。
翻译自: https://flaviocopes.com/docker-containers-command-line/
docker 容器 命令行