Course outline
Module 1
Module 1: Introduction to Docker and Containers
Introduction to Docker and Containers
Knowledge check
Q1. What is a container in the context of Docker?
- A. A virtual machine that runs on top of the host operating system
- B. A lightweight, standalone, executable package that includes everything needed to run an application ✓
- C. A tool used for managing Docker images
- D. A service that provides cloud-based container hosting
Why: Containers are lightweight and contain all the necessary components to run an application, but they do not include a full operating system like virtual machines.
Q2. Which of the following is a primary benefit of using containers?
- A. They require more system resources than traditional virtual machines
- B. They provide isolation and consistency across different environments ✓
- C. They cannot be scaled easily
- D. They are not portable between different systems
Why: Containers provide isolation and consistency, making it easier to develop, deploy, and run applications across different environments.
Q3. What is Docker Hub?
- A. A command-line tool used to build Docker images
- B. A cloud-based service for running Docker containers
- C. A registry where Docker images are stored and shared ✓
- D. A tool for monitoring Docker containers
Why: Docker Hub is a registry where Docker images are stored and shared, allowing users to find and use images created by others.
Q4. Which command is used to run a Docker container?
- A. docker build
- B. docker run ✓
- C. docker image
- D. docker create
Why: The 'docker run' command is used to run a container from an image.
Q5. What is the main purpose of a Dockerfile?
- A. To run a Docker container
- B. To store Docker images
- C. To define the steps for building a Docker image ✓
- D. To manage Docker containers
Why: A Dockerfile contains instructions to build a Docker image, defining the environment and setup needed for the application.
Module 2
Module 2: Understanding Containerization
Understanding Containerization
Knowledge check
Q1. What is the primary purpose of containerization?
- A. To replace virtual machines entirely
- B. To package applications and their dependencies into isolated containers ✓
- C. To provide a way to manage cloud infrastructure
- D. To improve network security
Why: Containerization allows applications to be packaged with their dependencies, ensuring consistency across different environments.
Q2. Which of the following is a benefit of using containers?
- A. Increased hardware requirements
- B. Improved portability and consistency across environments ✓
- C. Reduced application performance
- D. Higher security risks
Why: Containers provide portability and consistency by encapsulating applications and their dependencies.
Q3. What is a Docker image?
- A. A running instance of a container
- B. A file that contains all the necessary information to run a container ✓
- C. A command used to start a container
- D. A type of virtual machine
Why: A Docker image is a file that contains all the necessary information to run a container.
Q4. What does the Dockerfile define?
- A. The runtime configuration of a container
- B. The instructions to build a Docker image ✓
- C. The network settings for a container
- D. The user permissions for a container
Why: A Dockerfile contains instructions to build a Docker image.
Q5. Which of the following is NOT a containerization tool?
- A. Docker
- B. Kubernetes
- C. LXC
- D. VirtualBox ✓
Why: VirtualBox is a virtualization tool, not a containerization tool.
Module 3
Module 3: Installing and Configuring Docker
Installing and Configuring Docker
Knowledge check
Q1. What command is used to install Docker on a Ubuntu system?
- A. sudo apt install docker
- B. sudo apt-get install docker.io ✓
- C. sudo yum install docker
- D. sudo dnf install docker
Why: The correct command for installing Docker on Ubuntu is `sudo apt-get install docker.io` because `apt-get` is the package management tool used in Ubuntu and `docker.io` is the correct package name.
Q2. Which Docker command is used to start a Docker service?
- A. docker start
- B. systemctl start docker ✓
- C. docker run
- D. docker service start
Why: The correct command to start the Docker service is `systemctl start docker` because Docker is managed as a systemd service on most Linux distributions.
Q3. What is the default port used by Docker's internal network?
- A. 2375 ✓
- B. 2376
- C. 2377
- D. 2378
Why: The default port used by Docker's internal network is 2375, which is used for communication between Docker components.
Q4. Which Docker command is used to check the status of the Docker service?
- A. docker status
- B. systemctl status docker ✓
- C. docker info
- D. docker service status
Why: The correct command to check the status of the Docker service is `systemctl status docker` because Docker is managed as a systemd service on most Linux distributions.
Q5. Which command is used to enable Docker to start on boot in a systemd-based system?
- A. docker enable
- B. systemctl enable docker
- C. sudo systemctl enable docker ✓
- D. sudo docker enable
Why: The correct command to enable Docker to start on boot is `sudo systemctl enable docker` because `systemctl` is the command used to manage systemd services, and `enable` sets the service to start on boot.
Module 4
Module 4: Creating and Managing Docker Images
Creating and Managing Docker Images
Knowledge check
Q1. What command is used to build a Docker image from a Dockerfile?
- A. docker build ✓
- B. docker create
- C. docker run
- D. docker image
Why: The 'docker build' command is used to build an image from a Dockerfile.
Q2. Which Dockerfile instruction is used to specify the base image for the Docker image?
- A. FROM ✓
- B. RUN
- C. CMD
- D. LABEL
Why: The 'FROM' instruction specifies the base image for the Docker image.
Q3. What is the purpose of the 'docker commit' command?
- A. To build an image from a Dockerfile
- B. To create a new image from a running container ✓
- C. To push an image to a registry
- D. To remove an image
Why: The 'docker commit' command is used to create a new image from a running container.
Q4. Which command lists all Docker images on a system?
- A. docker images ✓
- B. docker ps
- C. docker info
- D. docker inspect
Why: The 'docker images' command lists all Docker images on a system.
Q5. What does the 'docker image tag' command do?
- A. Tags an image with a new name and tag ✓
- B. Deletes an image
- C. Builds an image
- D. Pushes an image to a registry
Why: The 'docker image tag' command is used to tag an image with a new name and tag.
Module 5
Module 5: Dockerfile Best Practices
Dockerfile Best Practices
Module 6
Module 6: Running Containers and Managing State
Running Containers and Managing State
Knowledge check
Q1. What is the primary purpose of using Docker volumes?
- A. To store container logs
- B. To persist data beyond the lifecycle of a container ✓
- C. To manage container networking
- D. To run multiple containers on the same host
Why: Docker volumes are used to persist data outside the container's filesystem, ensuring data is not lost when the container is removed.
Q2. Which command is used to create a named volume in Docker?
- A. docker volume create ✓
- B. docker run -v
- C. docker build -v
- D. docker commit -v
Why: The 'docker volume create' command is used to create a named volume in Docker.
Q3. Which of the following is NOT a way to manage container state?
- A. Using Docker volumes
- B. Using bind mounts
- C. Using Docker images ✓
- D. Using Docker containers
Why: Docker images are used to create containers, but they do not directly manage container state.
Q4. What happens to data stored in a Docker volume when the container is removed?
- A. Data is deleted permanently
- B. Data is moved to a backup location
- C. Data remains intact in the volume ✓
- D. Data is encrypted and stored separately
Why: Data stored in a Docker volume persists even if the container is removed, as volumes are separate from the container's filesystem.
Q5. Which of the following is a benefit of using Docker volumes over bind mounts?
- A. Volumes are easier to manage and more portable ✓
- B. Volumes are faster in read/write operations
- C. Volumes are only available on the host machine
- D. Volumes do not require any configuration
Why: Volumes are more portable and easier to manage compared to bind mounts, which rely on the host's filesystem paths.
Module 7
Module 7: Networking and Communication in Docker
Networking and Communication in Docker
Knowledge check
Q1. What is the default network driver used by Docker?
- A. bridge ✓
- B. host
- C. overlay
- D. macvlan
Why: The default network driver in Docker is bridge, which creates a private internal network for containers.
Q2. Which Docker network allows containers to communicate with the host machine directly?
- A. bridge
- B. host ✓
- C. overlay
- D. macvlan
Why: The host network driver allows containers to share the host's network stack, enabling direct communication with the host.
Q3. Which command is used to create a custom Docker network?
- A. docker network create ✓
- B. docker network new
- C. docker network setup
- D. docker network build
Why: The 'docker network create' command is used to create a new custom network in Docker.
Q4. Which Docker network is used for multi-host communication in Docker Swarm?
- A. bridge
- B. host
- C. overlay ✓
- D. macvlan
Why: The overlay network is used for multi-host communication in Docker Swarm, allowing containers on different hosts to communicate.
Q5. What is the purpose of the 'docker network inspect' command?
- A. To create a new network
- B. To delete an existing network
- C. To view details of a network ✓
- D. To connect a container to a network
Why: The 'docker network inspect' command is used to view detailed information about a Docker network.