Introduction
By default docker run attaches your terminal to the container — when you close the terminal the container stops. Detached mode runs the container in the background so it keeps running independently of your terminal session.
When you start a web server or database container that should keep running after you close your terminal.
When you deploy multiple containers in a script and don't want to wait for each one interactively.
When you run a container on a remote server over SSH and want it to keep running after disconnecting.
When you want to start a container and immediately check its logs or status without being attached.
When you run containers as part of a CI/CD pipeline that needs to continue after launch.