0
0
Dockerdevops~5 mins

Running containers in detached mode in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does running a Docker container in detached mode mean?
Running a Docker container in detached mode means the container runs in the background, allowing you to continue using the terminal without being attached to the container's output.
Click to reveal answer
beginner
Which Docker command option runs a container in detached mode?
The -d option in the docker run command runs the container in detached mode.
Click to reveal answer
beginner
How can you check running containers after starting one in detached mode?
Use the command docker ps to list all running containers, including those started in detached mode.
Click to reveal answer
intermediate
What is the difference between running a container in attached vs detached mode?
Attached mode shows the container's output in the terminal and keeps the terminal busy. Detached mode runs the container in the background, freeing the terminal for other commands.
Click to reveal answer
beginner
How do you stop a container running in detached mode?
You can stop a detached container using docker stop <container_id_or_name>.
Click to reveal answer
Which command runs a Docker container in detached mode?
Adocker run --rm nginx
Bdocker run -it nginx
Cdocker run -d nginx
Ddocker run --name nginx
What does the docker ps command show?
AAll running containers
BAll stopped containers
CDocker images
DDocker volumes
If you want to see the logs of a detached container, which command do you use?
Adocker exec &lt;container_id&gt;
Bdocker attach &lt;container_id&gt;
Cdocker stop &lt;container_id&gt;
Ddocker logs &lt;container_id&gt;
What happens if you run a container without -d option?
AContainer runs attached to terminal
BContainer runs in background
CContainer stops immediately
DContainer runs with no network
How do you stop a container running in detached mode?
Adocker start &lt;container_id&gt;
Bdocker stop &lt;container_id&gt;
Cdocker run -d &lt;container_id&gt;
Ddocker rm &lt;container_id&gt;
Explain what detached mode is in Docker and why you might want to use it.
Think about running a program and still being able to use your computer for other things.
You got /3 concepts.
    Describe the steps to run a container in detached mode and then check if it is running.
    Start with the command to run, then how to verify.
    You got /2 concepts.