Docker
Docker Fundamentals - Getting Started

Letting Things Run

PRO

Letting Things Run

Each time you run the command docker container run a new container is created. Sometimes you may want to reuse containers or come back to previously created containers. Pressing control + D quits a shell and terminates the container.

Pressing control + P and control + Q allows you to detach from a container without closing it. You can re-attach with the command docker container attach [NAME-OF-CONTAINER].

You can use the command hostname to verify that you are still in the same container.

The command docker container ls lists all running containers.

The command docker container ls -a lists all containers, even those not running.

Containers can be restarted using the command docker container start [NAME-OF-CONTAINER].

To stop a container use the command docker container stop [NAME-OF-CONTAINER].

You can start a container in detached mode using the command docker container run -itd [NAME-OF-CONTAINER] sh.