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.
We'll cover the following...
We'll cover the following...
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 bashUnable to find image 'ubuntu:24.04' locally24.04: Pulling from library/ubuntu51ae9e2de052: Download completeDigest: sha256:ff0b5139e774bb0dee9ca8b572b4d69eaec2795deb8dc47c8c829becd67de41eStatus: Downloaded newer image for ubuntu:24.04root@d3c892ad0eb3:/#
Start a new interactive container called ddd-ctr