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?
✗ Incorrect
The
-d option runs the container in the background (detached mode).How do you map port 5000 on your computer to port 80 in the container?
✗ Incorrect
The syntax is
-p hostPort:containerPort, so -p 5000:80 maps host port 5000 to container port 80.What does
docker run --name myapp image do?✗ Incorrect
The
--name option assigns a custom name to the container.If you want to interact with a container's terminal, which option should you add?
✗ Incorrect
The
-it option allows interactive terminal access to the container.What is the default behavior if no command is given in
docker run?✗ Incorrect
Docker runs the default command specified in the image's configuration.
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.