lxcdocker

Launch a container with Docker without specifying command


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 ?


Solution

  • With docker, from the CLI, you can't create a container without running a command on it. If you want to use the REST Api, you can call the 'create' endpoint without 'start'.

    However, it wouldn't be any good for you I think.

    In most case, you probably just want to run a container with bash docker run -t -i ubuntu bash and do stuff there. Once you did everything you needed, you can simply commit and run from this point.

    Usually however, it is better to do one step at a time in order to keep a clear history. Take a look at the Docker builder :)