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.
If you do not want to install anything into your current running Docker server setup, you can simply execute (replace
$CONTAINER_NAME
with the container name you want to have the run arguments):(for the
rekcod
method)or
(for the
runlike
method)Currently it seems we have to go 'docker inspect ' and then manually recreate the run command.
I have found someone attempting to write a bash script to do this: https://gist.github.com/miracle2k/c85b7b077fdb8d54bc89
but it is incomplete and depends on jq.
Use following command to get the arguments for all containers docker inspect -f "{{.Name}} {{.Path}} {{.Args}}" $(docker ps -a -q)
I wrote a simple Node-based CLI tool to generate a
docker run
command from an existing container.https://www.npmjs.com/package/rekcod
Here's an example:
Also handles links and mounted volumes and other stuff.
Not super robust at the moment, but handles more than some of the other things mentioned, and it was more of what I was looking for.