Search⌘ K
AI Features

Terminating the Main Process of a Container

Explore how terminating the main process impacts a Docker container's lifecycle, and learn commands to manage container states effectively. Understand how to exit containers without stopping them and how to restart containers to maintain workflow continuity.

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

List all running processes

...