docker常用命令
最近应一个老朋友的邀请,整理一下docker的命令,在之后的章节会把每个命令都详细讲述一遍,随便在之后的篇章里面总结一下kubernetes
docker常用命令 | 系统解释 | 主要功能作用 |
---|---|---|
attach | Attach local standard input, output, and error streams 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 | 创建一个新的容器 |
diff | Inspect changes to files or directories 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文档 |
history | Show the history of an image | 展示一个镜像的操作历史 |
images | List images | 列出当前所有镜像 |
import | Import the contents from a tarball to create a filesystem image | 导入一个tar包创建一个系统镜像 |
info | Display system-wide information | 显示docker系统信息 |
inspect | Return low-level information on Docker objects | 获取容器/镜像的元数据 |
kill | Kill one or more running containers | kill掉一个或者多个运行的容器 |
load | Load an image from a tar archive or STDIN | 导入使用docker save命令导出的镜像 |
login | Log in to a Docker registry | 登录到docker仓库 |
logout | Log out from a Docker registry | 登出 |
logs | Fetch the logs of a container | 查看docker日志 |
pause | Pause all processes within one or more containers | 暂停容器中的所有进程 |
port | List port mappings or a specific mapping for the container | 列出指定容器的端口映射 |
ps | List containers | 列出容器 |
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 one or more containers | 重启一个或多个容器 |
rm | Remove one or more containers | 移除一个或多个容器 |
rmi | Remove one or more images | 移除一个或多个镜像 |
run | Run a command in a new container | 创建一个容器 |
save | Save one or more images to a tar archive (streamed to STDOUT by default) | 将指定的镜像保存成tar包 |
search | Search the Docker Hub for images | 从docker hub查找镜像 |
start | Start one or more stopped containers | 开始一个或多个镜像 |
stats | Display a live stream of container(s) resource usage statistics | 显示容器资源使用统计 |
stop | Stop one or more running containers | 停止一个或多个镜像 |
tag | Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE | 标记本地镜像 |
top | Display the running processes of a container | 查看容器中运行的进程 |
unpause | Unpause all processes within one or more containers | 恢复容器中所有的进程 |
update | Update configuration of one or more containers | 更新一个或多个容器的配置 |
version | Show the Docker version information | 显示docekr版本信息 |
wait | Block until one or more containers stop, then print their exit codes | 阻塞运行直到容器停止,然后打印出它的退出代码 |
[root@localhost ~]# docker --help #通过--help来查看docker的所有命令
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options: #这个我们先不管
--config string Location of client config files (default "/root/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with
"docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/root/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands: #这个是管理命令我们也先不管
app* Docker App (Docker Inc., v0.9.1-beta3)
builder Manage builds
buildx* Build with BuildKit (Docker Inc., v0.5.1-docker)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands: #这个就是我们要操心的啦
attach Attach local standard input, output, and error streams 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 #创建一个新的容器
diff Inspect changes to files or directories 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文档
history Show the history of an image #展示一个镜像的操作历史
images List images #列出当前所有镜像
import Import the contents from a tarball to create a filesystem image #导入一个tar包创建一个系统镜像
info Display system-wide information #显示docker系统信息
inspect Return low-level information on Docker objects #获取容器/镜像的元数据
kill Kill one or more running containers #kill掉一个或者多个运行的容器
load Load an image from a tar archive or STDIN #导入使用docker save命令导出的镜像
login Log in to a Docker registry #登录到docker仓库
logout Log out from a Docker registry #登出
logs Fetch the logs of a container #查看docker日志
pause Pause all processes within one or more containers #暂停容器中的所有进程
port List port mappings or a specific mapping for the container #列出指定容器的端口映射
ps List containers #列出容器
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 one or more containers #重启一个或多个容器
rm Remove one or more containers #移除一个或多个容器
rmi Remove one or more images #移除一个或多个镜像
run Run a command in a new container #创建一个容器
save Save one or more images to a tar archive (streamed to STDOUT by default) #将指定的镜像保存成tar包
search Search the Docker Hub for images #从docker hub查找镜像
start Start one or more stopped containers #开始一个或多个镜像
stats Display a live stream of container(s) resource usage statistics #显示容器资源使用统计
stop Stop one or more running containers #停止一个或多个镜像
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE #标记本地镜像
top Display the running processes of a container #查看容器中运行的进程
unpause Unpause all processes within one or more containers #恢复容器中所有的进程
update Update configuration of one or more containers #更新一个或多个容器的配置
version Show the Docker version information #显示docekr版本信息
wait Block until one or more containers stop, then print their exit codes #阻塞运行直到容器停止,然后打印出它的退出代码
Run 'docker COMMAND --help' for more information on a command.
To get more help with docker, check out our guides at https://docs.docker.com/go/guides/