albert
albert

Reputation: 1816

How to create, start and exec a container without command run?

To understando how to work the commands on docker, i tried create containers without the run command, but it dont work. I create a container

$ docker create <image id>

so, i tried to start

$ docker start <container id>

and this return the container id. So, i exec this command

$ docker exec <container id> sh

what generate the error:

Error response from daemon: Container 985547c13d7e3434cc32c0c8bdb1b26fd76ebc95771bc55588866b170852e747 is not running

So, how to create a container and exec a shell to attach ( $ docker attach ) without use run command? The create command seens useless if we cant start and exec on follow.

Upvotes: 1

Views: 1494

Answers (1)

Sha
Sha

Reputation: 166

I think you need to do following steps

create image

docker create -t -i <image ID> /bin/bash

start container interactive mode

docker start -a -i <container ID>

Upvotes: 1

Related Questions