0
0
Dockerdevops~5 mins

Running a container with docker run - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the docker run command do?
It creates and starts a new container from a specified Docker image.
Click to reveal answer
beginner
How do you run a container in the background (detached mode)?
Use the -d option with docker run, like docker run -d image_name.
Click to reveal answer
beginner
What option allows you to map a container port to a host port?
The -p option, for example docker run -p 8080:80 image_name maps host port 8080 to container port 80.
Click to reveal answer
beginner
How can you give a container a custom name when running it?
Use the --name option, like docker run --name mycontainer image_name.
Click to reveal answer
beginner
What happens if you run docker run without specifying a command?
Docker runs the default command defined in the image's CMD or ENTRYPOINT.
Click to reveal answer
Which option runs a Docker container in detached mode?
A-p
B--name
C-d
D-it
How do you map port 5000 on your computer to port 80 in the container?
Adocker run -p 5000:80 image
Bdocker run -p 80:5000 image
Cdocker run --port 5000:80 image
Ddocker run -port 80:5000 image
What does docker run --name myapp image do?
ANames the image as myapp
BNames the container as myapp
CRuns the container with default name
DDeletes the container named myapp
If you want to interact with a container's terminal, which option should you add?
A-it
B-p
C-d
D--name
What is the default behavior if no command is given in docker run?
AThrows an error
BContainer will not start
CRuns an interactive shell
DRuns the image's default command
Explain how to run a Docker container in detached mode with a custom name and port mapping.
Think about options for background, naming, and ports.
You got /6 concepts.
    Describe what happens when you run docker run without specifying a command or options.
    Focus on Docker image defaults.
    You got /3 concepts.