Launch a container with Docker without specifying command

rmonjo picture rmonjo · Jun 30, 2013 · Viewed 35.1k times · Source

I'm familiar with LXC and wanted to try out docker. The issue I'm facing is that I can't find a way to just tell docker to start a container in the background, without executing a command. For example, with LXC I would do :

lxc create -t ubuntu -n my_container

lxc-start -n my_container -d

At this point I would have a running container I can use as any VM (ssh to it, install stuff in it ...) It seems that docker prevent this kind of usage. Am I missing something ?

Answer

GameSalutes picture GameSalutes · Oct 27, 2015

When I need to inspect a docker container that I've created that is having issues running the normal CMD in the Dockerfile, I comment out that command and replace with "sleep" command to just pause the container when it starts so I can log into it and inspect the installation.

In Dockerfile

CMD ["sleep","3600"]

To log into the running Docker instance

docker exec -i -t <Container ID> bash