Docker Container

Table of contents
  1. Show running containers
  2. Execute command in container
    1. Open a container shell
  3. Start an existing container in background (detached)
  4. Attach container

Show running containers

docker ps

Execute command in container

docker exec -it my-container <command>

Open a container shell

docker exec -it my-container sh

Start an existing container in background (detached)

The container will run in background and you will not see its stdout/stderr

docker start my-container

Attach container

If you want to see outputs from the container in your terminal (ie. logging), you would want to run the container in attached mode.

You can either run it in attached mode to begin with by

docker start my-container --attach
# OR
docker start my-container -a

Or you can attach a running container later

docker attach my-container