如何显示Docker容器的运行命令 [英] How to show the run command of a docker container

查看:142
本文介绍了如何显示Docker容器的运行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用第三方GUI(Synology Docker软件包)来设置Docker容器。但是,它的局限性使我需要从命令行运行容器。 (我想映射另一个主机ip来绑定端口)

I use a third party GUI (Synology Docker package) to setup a docker container. However, it's limitation makes me need to run the container from the command line. (I want to map another host ip to bind the port)

现在,由于已经完成了许多设置,因此我想检索原始的run命令,启动此容器,然后可以将端口映射端口更改为新的。例如。 docker run -p 80:8080 gitlab

Now, since there are lots of settings that already done, I would like to retrieve the original run command that start this container, then I can change the port mapping port to new one. eg. "docker run -p 80:8080 gitlab"

我找不到这样做的方法,事件使用泊坞检查,但未提供此类信息。

I can't find the way to do so, event use "docker inspect", no such information provided.

请提供一些建议以解决此问题。

Please provide some advice to solve this problem.

推荐答案


那么如何反向工程docker run命令?

So how to reverse engineering docker run command?

有一个github存储库尝试反向工程docker run命令,但目前尚不完善,版本为 0.1.2 。您应该遵循它进行更新。也许有一天您可以使用它来获取正确的运行命令。

There is a github repository which try to reverse engineering docker run command, but it is not perfect currently, version is 0.1.2. You should follow it for updating. Maybe one day you can use it to get correct run command with it.

$ sudo pip install runlike

# run the ubuntu image
$ docker run -ti ubuntu bash

$ docker ps -a  
# suppose you get the container ID 1dfff2ba0226

# Run runlike to get the docker run command. 
$ runlike 1dfff2ba0226
docker run --name=elated_cray -t ubuntu bash

Github存储库: runlike

Github repository: runlike

无需安装即可运行(感谢@tilo)

Run without installing (Thanks @tilo)

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
    assaflavie/runlike YOUR-CONTAINER

或设置别名

alias runlike="docker run --rm -v/var/run/docker.sock:/var/run/docker.sock 
 assaflavie/runlike"

runlike YOUR-CONTAINER

这篇关于如何显示Docker容器的运行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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