获取容器的docker run命令 [英] Get docker run command for container
问题描述
我有一个创建的容器,但我不记得我用来启动它的确切的 docker run
命令。
I have a container that I created, but I can't remember the exact docker run
command I used to kick it off. Is there any way that can be retrieved?
这与查看Docker中正在运行/已停止的容器的完整命令我想知道的是产生该容器的完整docker命令,而不是内部的命令
This is not the same as See full command of running/stopped container in Docker What I want to know is the full docker command that spawned the container, not the command within the container.
推荐答案
您可以通过查看 docker inspect 的输出来推断大部分信息。 code>。
You can infer most of that information by looking at the output of docker inspect
.
例如,您可以通过查看 Config.Cmd $ c来发现容器内启动的命令。 $ c>键。如果我运行:
For example, you can discover the command started inside the container by looking at the Config.Cmd
key. If I run:
$ docker run -v /tmp/data:/data --name sleep -it --rm alpine sleep 600
我以后可以运行:
$ docker inspect --format '{{.Config.Cmd}}' sleep
并获得:
{[sleep 600]}
类似地, docker inspect
的输出还将包含有关容器中使用的Docker卷的信息:
Similarly, the output of docker inspect
will also include information about Docker volumes used in the container:
$ docker inspect --format '{{.Volumes}}' sleep
map[/data:/tmp/data]
您当然可以运行 docker inspect $ c没有
-format
的$ c>,它将为您提供一大段(100多行)JSON输出,其中包含所有可用键,其中包括有关端口映射,网络的信息配置等等。
You can of course just run docker inspect
without --format
, which will give you a big (100+ lines) chunk of JSON output containing all the available keys, which includes information about port mappings, network configuration, and more.
这篇关于获取容器的docker run命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!