Docker 常用命令简介

说是简介,其实也就是翻译+说明,加深一下自己印象的同时,也留个备份吧。

attach

Attach to a running container. 进入运行中的容器,显示该容器的控制台界面。注意,从该指令退出会导致容器关闭。

build

Build an image from a Dockerfile. 根据 Dockerfile 文件构建镜像。

commit

Create a new image from a container's changes. 提交容器所更改的,创建为一个新的镜像。

cp

Copy files/folders between a container and the local filesystem. 在容器和宿主机之间复制文件或文件夹。

create

Create a new container. 根据镜像生成一个新的容器(run 命令的简化版,用于快速启动镜像)。

diff

Inspect changes on a container's filesystem. 展示容器相对于构建它的镜像内容所做的改变。

events

Get real time events from the server. 实时打印服务端执行的事件。

exec

Run a command in a running container. 在已运行的容器中执行命令。

export

Export a container's filesystem as a tar archive. 导出容器到本地快照文件(tar 压缩包)。

import

Import the contents from a tarball to create a filesystem image. 导入本地容器快照文件为镜像。

history

Show the history of an image. 显示镜像每层的变更内容。

images

List images. 列出本地所有镜像。

info

Display system-wide information. 显示 Docker 详细的系统信息。

inspect

Return low-level information on a container, image or task. 查看容器或镜像的配置信息,默认为 json 数据。

kill

Kill one or more running containers. -s 选项向容器发送信号,默认为 SIGKILL 信号(强制关闭)。

load

Load an image from a tar archive or STDIN. 导入镜像压缩包。

login

Log in to a Docker registry. 登录第三方仓库。

logout

Log out from a Docker registry. 退出第三方仓库。

logs

Fetch the logs of a container. 打印容器的控制台输出内容。

network

Manage Docker networks. 管理容器网络,默认为 bridge、host、none 三个网络配置。

pause

Pause all processes within one or more containers. 暂停容器。

unpause

Unpause all processes within one or more containers. 恢复暂停的容器。

port

List port mappings or a specific mapping for the container. 容器端口映射列表。

ps

List containers. 列出正在运行的容器,-a 选项显示所有容器。

pull

Pull an image or a repository from a registry. 从镜像仓库拉取镜像。

push

Push an image or a repository to a registry. 将镜像推送到镜像仓库。

rename

Rename a container. 重命名容器名。

restart

Restart a container. 重启容器。

rm

Remove one or more containers. 删除已停止的容器,-f 选项可强制删除正在运行的容器。

rmi

Remove one or more images. 删除镜像(必须先删除该镜像构建的所有容器)。

run

Run a command in a new container. 根据镜像生成并进入一个新的容器。

run vs create

The docker create command creates a writeable container layer over the specified image and prepares it for running the specified command. The container ID is then printed to STDOUT. This is similar to docker run -d except the container is never started. You can then use the docker start command to start the container at any point. This is useful when you want to set up a container configuration ahead of time so that it is ready to start when you need it. The initial status of the new container is created. Technically, docker run = docker create + docker start.

save

Save one or more images to a tar archive (streamed to STDOUT by default). 打包本地镜像,使用压缩包来完成迁移。

search

Search the Docker Hub for images. 从仓库查找镜像。

start

Start one or more stopped containers. 启动关闭的容器。

stats

Display a live stream of container(s) resource usage statistics. 显示容器对资源的使用情况,内存、CPU、磁盘等。

stop

Stop one or more running containers. 关闭正在运行的容器。

tag

Tag an image into a repository. 修改镜像 tag。

top

Display the running processes of a container. 显示容器中正在运行的进程(相当于容器内执行 ps -ef 命令)。

update

Update configuration of one or more containers. 更新容器的硬件资源限制(内存、CPU等)。

version

Show the Docker version information. 显示 docker 客户端和服务端版本信息。

volume

Manage Docker volumes. 管理数据卷。

wait

Block until a container stops, then print its exit code. 阻塞当前命令直到对应的容器被关闭, 容器关闭后打印结束代码。

swarm

Manage Docker Swarm. 管理 Swarm 模式。

service

Manage Docker services. 管理 Swarm 模式下的服务。

node

Manage Docker Swarm nodes. 管理 Swarm 模式下的 docker 集群中的节点。

help

Run 'docker COMMAND --help' for more information on a command. 所有的命令都可以使用 docker 命令 --help 来获取使用信息。
消息盒子

# 暂无消息 #

只显示最新10条未读和已读信息