从容器重构docker run命令参数 [英] Reconstruct docker run command parameters from container

查看:197
本文介绍了从容器重构docker run命令参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从现有Docker容器中重建 docker run 命令参数的最佳方法是什么?我可以使用 docker inspect 并使用在那里找到的信息。有什么更好的方法吗?

What's the best way to reconstruct docker run command parameters from existing docker container? I could use docker inspect and use the info found there. Is there any better way?

推荐答案

并非超级简单,但是您可以通过格式化 docker检查。对于以以下命令开头的容器:

Not super easy, but you can do it by formatting the output from docker inspect. For a container started with this command:

> docker run -d -v ~:/home -p 8080:80 -e NEW_VAR=x --name web3 nginx:alpine sleep 10m

您可以使用以下命令拉出卷,端口映射,环境变量,容器名称,映像名称和命令:

You can pull out the volumes, port mapping, environment variables, container name, image name and command with:

> docker inspect -f "V: {{.Mounts}} P: {{.HostConfig.PortBindings}} E:{{.Config.Env}} NAME: {{.Name }} IMAGE: {{.Config.Image}} COMMAND: {{.Path}} {{.Args}}" web3

输出:

V: [{ /home/scrapbook /home   true rprivate}] P: map[80/tcp:[{ 8080}]] E:[NEW_VAR=x PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NGINX_VERSION=1.11.5] NAME: /web3 IMAGE: nginx:alpine COMMAND: sleep [10m]

这是一个开始。

Docker船长 Adrian Mouat 上有一篇很棒的博客文章格式化输出: Docker检查模板魔术

Docker Captain Adrian Mouat has an excellent blog post on formatting the output: Docker Inspect Template Magic.

这篇关于从容器重构docker run命令参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆