Docker run command is used to create a docker container out of docker images. This tutorial is to tell ways to create docker container in detached mode.
So, the first question that came in the mind is what is detached mode. Detached mode means that the when the root process of the host machine on which docker engine is installed exits, the docker container started in detached mode also exits.
So, the first question that came in the mind is what is detached mode. Detached mode means that the when the root process of the host machine on which docker engine is installed exits, the docker container started in detached mode also exits.
How to start docker container in detached mode?
docker run -d=true
docker run -d
You can start the docker container in detached mode using -d=true (or simply -d) options with docker run interface.
By default, the docker container starts in foreground mode.
Points to remember when docker container is started in detached mode:
(a) Docker container will not automatically be removed when you stop the container.
(b) Don't start container in detached mode using unix service command. The problem it will face here is that unix service process returns (and exits), so the container will also stop in detached mode due to this.