Stopping Containers Gracefully

Examine why a two-stage approach of stopping the container before deleting it is recommended.

We'll cover the following

Two stage approach

Most containers in the Linux world will run a single process. Things are a bit different with Windows containers, but they still run a single main application process and the following rules apply.

Suppose you have a container running the /bin/bash app. When you kill a running container with docker container rm <container> -f, the container is killed without warning. The procedure is quite violent. It is a bit like sneaking up behind the container and shooting it in the back of the head. You’re literally giving the container and the app it’s running, no chance to complete any operation and gracefully exit.

Get hands-on with 1200+ tech skills courses.