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)
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.
A simpler (?) alternative is to run this docker inspect template, which uses the builtin Go templating capabilities to output a
docker run
compatible command. The template only covers the most usual command-line options, but it can easily be extended.This solution has no dependencies on other tools, except docker itself.
To reverse the docker run command there is also the following npm package.
https://github.com/nexdrew/rekcod
What could be a simpler (robust) option would be to use something like bash-preexec to capture commands that start with "docker run". You could then store these commands somewhere and retrieve them later.
For example, you could add something like this in your bash profile:
Then you could just run your things:
Which outputs:
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.Github repository: runlike
Updates:
Run without installing (Thanks @tilo)
That docker run command isn't specified in the Dockerfile or any other docker-related documents.
Either you find an example in the documentation associated to your container, or you can infer that docker run with (at least for the command and port mapping) a
docker ps -a
(but that won't give you the possible--volumes-from
options)Check also
/usr/syno/etc/packages/Docker-GitLab/config
This differ from the gitlab config itself, which on Synology is available in
/usr/syno/etc/packages/Docker/synology_gitlab.config
Use docker inspect:
You can programatically parse this with jq: