0
0
Dockerdevops~5 mins

Restarting containers in Docker - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command is used to restart a running Docker container?
Use docker restart <container_name_or_id> to stop and then start a container again.
Click to reveal answer
beginner
What happens when you run docker restart on a container?
Docker stops the container if it is running, then starts it again. It does not apply any changes made to the container's configuration or environment.
Click to reveal answer
intermediate
How can you restart all running Docker containers at once?
You can use docker restart $(docker ps -q) to restart all running containers by passing their IDs to the restart command.
Click to reveal answer
intermediate
What is the difference between docker restart and docker stop followed by docker start?
docker restart combines stopping and starting in one command, while docker stop and docker start are two separate commands that achieve the same result.
Click to reveal answer
intermediate
Can you specify a timeout when restarting a Docker container? How?
Yes, use docker restart -t <seconds> <container> to set how long Docker waits before forcibly stopping the container.
Click to reveal answer
Which command restarts a Docker container named 'webapp'?
Adocker reload webapp
Bdocker restart webapp
Cdocker reset webapp
Ddocker refresh webapp
What does the -t option do in docker restart -t 5 mycontainer?
ATests the container before restarting
BSpecifies the total restart attempts
CTags the container with a label
DSets the timeout in seconds before forcefully stopping the container
How can you restart all running containers with one command?
Adocker restart $(docker ps -q)
Bdocker restart --all
Cdocker restart -a
Ddocker restart *
What is the effect of running docker restart on a stopped container?
AIt removes the container
BIt does nothing
CIt starts the container
DIt pauses the container
Which command sequence is equivalent to docker restart mycontainer?
Adocker stop mycontainer && docker start mycontainer
Bdocker pause mycontainer && docker unpause mycontainer
Cdocker kill mycontainer && docker run mycontainer
Ddocker remove mycontainer && docker create mycontainer
Explain how to restart a Docker container and what happens during the restart process.
Think about what stopping and starting means for a container.
You got /4 concepts.
    Describe a method to restart all running Docker containers at once and why this might be useful.
    Consider how to get all container IDs and use them in one command.
    You got /4 concepts.