Bootstrap FreeKB - Docker - Run container in background using the docker run --detach command
Docker - Run container in background using the docker run --detach command

Updated:   |  Docker articles

By default, when creating a container using the docker run command, the command is run in the foreground, which means that your shell cannot be used to issue other commands, and you would have to use Ctrl C or Ctrl Z to regain your shell, which will stop the container. The --detach flag can be used to run the container in the background, so that you can use your shell to issue other commands.

In this example, a container is created using the foo:latest image and the container is run in the background.

Almost always, this is coupled with the --rm flag to remove the container after is has completed.

[john.doe@docker ~]# docker run --detach --rm foo:latest

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 8f25ee in the box below so that we can be sure you are a human.