Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get command used to start a Docker container

Tags:

docker

I have a Docker container running, and I want to create another one similar to it. How can I find out what command was used to start the container? There's docker inspect, but I'd have to go through and look at each of the config options one by one.

Edit: I want to get the full command used to start the container, including environment variables, links, volumes, etc. For example:

docker run -d --name foo -v /bar:/bar --link baz:baz -e DEBUG=True image bash 
like image 861
z0r Avatar asked Jun 20 '15 14:06

z0r


People also ask

What command can be used to start a container in docker?

You can then use the docker container start (or shorthand: docker start ) command to start the container at any point. This is useful when you want to set up a container configuration ahead of time so that it is ready to start when you need it. The initial status of the new container is created .

What command is used to start a container?

The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command. That is, docker run is equivalent to the API /containers/create then /containers/(id)/start .


1 Answers

The following will show the environment variables, the ENTRYPOINT of the Dockerfile, the CMDLINE, the volumes from, the volumes, the links.

docker inspect -f '{{ .Config.Env}} {{ .Config.Entrypoint}} {{ .Config.Cmd}} {{ .VolumesFrom}} {{.Volumes}}  {{ .HostConfig.links}}' container_id 
like image 114
user2915097 Avatar answered Sep 24 '22 23:09

user2915097