Docker Community Forums

Share and learn in the Docker community.

Idea of creating containers


(Stopsopa) #1

I already readed documentation and i’m little confused because from start to end in documentation is used “run” command which create another and another container. As a result when i run “sudo docker ps -a” i see that i have many containers each created in separate command.

  1. What is going on in this idea of constant creating new container?

  2. How can i manage already existing containers?

  3. And most important: How can i login to terminal to running container. The only way to see terminal of container is to create (create again) container by (for example): “sudo docker run -t -i centos /bin/bash”
    , and then if i exit from this container i can’t enter again.


(Andy Rothfusz) #2
  1. I’m not sure what you mean.

  2. You can manage your containers with commands like docker rm $(docker ps -aq), which will remove all non-running containers. If your containers are running, you could use docker stop + the container id or container name.

  3. You can re-enter an already running container with docker exec though we typically recommend only using this for debugging. You should instead plan to create images that know how to start up and connect automatically – there shouldn’t be any manual steps to running a container.