Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show the run command of a docker container

Tags:

docker

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.

like image 475
Jack Yu Avatar asked Oct 19 '22 17:10

Jack Yu


People also ask

How do I show docker running containers?

In order to list the Docker containers, we can use the “docker ps” or “docker container ls” command. This command provides a variety of ways to list and filter all containers on a particular Docker engine.

How can I see docker commands?

To list available commands, either run docker with no parameters or execute docker help : $ docker Usage: docker [OPTIONS] COMMAND [ARG...]

What is the Run command in docker?

The docker run command is the command used to launch Docker containers. As such, it's familiar to anyone starting or running Docker containers on a daily basis.


1 Answers

So how to reverse engineering docker run command?

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 repository: runlike

Updates:

Run without installing (Thanks @tilo)

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

or set alias and put it in your shell's profile

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

docker ps

runlike YOUR-CONTAINER
like image 219
BMW Avatar answered Oct 21 '22 07:10

BMW