【Docker系列】从头学起 Docker——docker --help命令详解


前言

当你在docker容器时相信docker --help一定可以帮助到你。

一、学会使用 docker --help 命令

即使忘记相关命令,也可以通过 docker --help 命令,人机交互,获取到相关命令使用信息。以下便是执行 docker --help 的相关提示。

[root@docker ~]# docker --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 //使用TLS;隐含 ——tlsverify
–tlscacert string Trust certs signed only by this CA (default “/root/.docker/ca.pem”) //仅由此CA签署的信任证书(默认 “/root/.docker/ca.pem”)
–tlscert string Path to TLS certificate file (default “/root/.docker/cert.pem”) // TLS证书文件的路径
–tlskey string Path to TLS key file (default “/root/.docker/key.pem”) // TLS密钥文件的路径
–tlsverify Use TLS and verify the remote //使用TLS且远程验证
-v, --version Print version information and quit // 打印版本信息并退出

Management Commands:
builder Manage builds // 管理生成
config Manage Docker configs // 管理 docker 配置
container Manage containers // 管理容器
context Manage contexts // 管理上下文
engine Manage the docker engine // 管理docker引擎
image Manage images // 管理镜像
network Manage networks // 管理网络
node Manage Swarm nodes // 管理集群节点
plugin Manage plugins // 管理插件
secret Manage Docker secrets // 管理 docker 密钥
service Manage services // 管理 docker 服务
stack Manage Docker stacks // 管理 docker 堆栈
swarm Manage Swarm // 管理集群
system Manage Docker // 系统管理员管理 docker
trust Manage trust on Docker images // 管理对 docker 镜像的信任
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 //从tarball导入内容以创建文件系统镜像
info Display system-wide information // 显示整个系统的信息
inspect Return low-level information on Docker objects // 返回Docker对象的底层信息
kill Kill one or more running containers // 杀死一个或多个正在运行的容器
load Load an image from a tar archive or STDIN // 从tar存档或STDIN加载镜像
login Log in to a Docker registry // 登录到Docker注册表
logout Log out from a Docker registry // 从Docker注册表注销
logs Fetch the logs of a container //获取容器的日志
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 // 创建一个引用SOURCE_IMAGE的TARGET_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 //显示Docker版本信息
wait Block until one or more containers stop, then print their exit codes // 阻塞,直到一个或多个容器停止,然后打印它们的退出代码

Run ‘docker COMMAND --help’ for more information on a command. //运行“docker COMMAND——help”获取命令的更多信息。

二、docker --help进阶方法

例如:我们想要查询 docker pull 命令的用法,可以执行 docker pull --help 。当然你可以尝试看看 docker run --help 的效果。

[root@docker ~]# docker pull --help

// 用法:docker pull [选项] 名称[:标签|摘要] 其中,中括号是可选项
Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]
// 从注册表中提取映像或存储库
Pull an image or a repository from a registry
//选项:
Options:
-a, --all-tags Download all tagged images in the repository // 下载存储库中所有标记的镜像
–disable-content-trust Skip image verification (default true)// 跳过图像验证(默认 true)
-q, --quiet Suppress verbose output // 禁止详细输出息
// 通过 docker pull --help 命令,我们知道选项有3个,这3个选项可以组合使用。
// 根据这些信息,我们可以知晓 docker pull 命令的用法
例如:docker pull -q redis:last // 拉取redis最新标签的镜像,禁止详细输出
//你也可以试一下其他命令的效果,多点尝试,更好的理解命令的用法。

总结

我们想记住这些命令作用和效果,还是离不开大量的练习。忘记命令了,不妨试一下 docker --help ,这样更有利于学习和记忆,更深入地了解 docker 命令的使用方法。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

搞什么滚去学习

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值