Choosing the Right Command
Which Docker command is used to build an image from a Dockerfile?
- docker run
- docker start
- docker build
- docker compose up
- docker image make
Port Mapping
How do you map a port on your host machine to a port inside a Docker container?
- Using the -p flag followed by host_port:container_port
- Using the -m flag followed by host_port:container_port
- By specifying port mappings in the Dockerfile
- By setting the PORT environment variable
- Using the --port flag
Detached Mode
Which flag allows you to run a Docker container in detached mode, meaning it runs in the background?
- -d
- -bg
- -detach
- -b
- --background
Docker Compose
What is the primary purpose of Docker Compose?
- To build a single Docker image
- To orchestrate multi-container Docker applications
- To monitor Docker container resource usage
- To manage Docker volumes
- To create Docker networks
Dockerfile Instruction: EXPOSE
What does the EXPOSE instruction in a Dockerfile do?
- Exposes a port on the host machine
- Documents the port the container listens on, but does not actually publish the port
- Maps a port directly to the host machine for external access
- Encrypts the port for secure communication
- Opens a specific port for remote debugging
Docker Volume
What is the purpose of using Docker volumes?
- To store container logs permanently
- To persist data generated by the container even after the container is stopped or removed
- To improve the container's network performance
- To reduce the size of the Docker image
- To encrypt data inside the container
Docker Networking
By default, how can containers communicate with each other within the same Docker network?
- Using their container names as hostnames
- Only through exposed ports
- They can't communicate by default without additional configuration
- Using the host machine's IP address
- Via shared volumes only
ENV Instruction in Dockerfile
What is the purpose of the ENV instruction in a Dockerfile?
- To set environment variables within the container
- To encrypt environment variables
- To expose environment variables to the host machine
- To limit environment variables
- To automatically update environment variables
Docker Image Layers
Why are Docker images built in layers?
- To minimize image size and improve build times through caching
- To improve container security
- To simplify image deployment
- To enable easier image versioning
- To make images more portable
Removing a Docker Container
Which command removes a stopped Docker container?
- docker stop
- docker rm
- docker remove
- docker delete
- docker kill