...

/

Terminating the Main Process of a Container

Terminating the Main Process of a Container

Learn how to manage a container by terminating its main process, restarting the container, attaching to its shell, and exiting the container without stopping it.

Earlier in the chapter, we learned that containers are designed to run a single process, and terminating this process also terminates the container. Let’s test if that’s true.

Run the following command to start a new interactive container named ddd-ctr based on the Ubuntu image, specifying Bash as its main process.

$ docker run --name ddd-ctr -it ubuntu:24.04 bash
Unable to find image 'ubuntu:24.04' locally
24.04: Pulling from library/ubuntu
51ae9e2de052: Download complete
Digest: sha256:ff0b5139e774bb0dee9ca8b572b4d69eaec2795deb8dc47c8c829becd67de41e
Status: Downloaded newer image for ubuntu:24.04
root@d3c892ad0eb3:/#
Start a new interactive container called ddd-ctr
...
Access this course and 1400+ top-rated courses and projects.