programming beginner 10 sample questions

Containerization MCQ Practice Test

Using Docker to package applications with all dependencies. Managing containerized apps on cloud platforms.

Q1. You're using Kubernetes to orchestrate your microservices. One service, responsible for image processing, is being restarted repeatedly, and kubectl events show numerous 'OOMKilled' events for its pods. Which is the MOST effective initial troubleshooting step?

Explanation: OOMKilled means the container exceeded its memory limit and the kernel killed it. The first response is to inspect actual memory usage (metrics, profiling, possible leaks) and correct the memory requests/limits - or fix the leak. Adding replicas just multiplies dying pods, node upgrades are a costly last resort, and resource quotas are cluster-wide governance, not a fix for one service.

Q2. You're using Docker Compose to orchestrate a multi-container application. One service depends on a database service. The database service's startup is unexpectedly slow, causing the dependent service to fail its health check before the database is fully operational. Which Docker Compose configuration adjustment would BEST mitigate this issue?

Explanation: Compose's depends_on with condition: service_healthy waits until the database container reports healthy (via its healthcheck) before starting the dependent service - this directly fixes the readiness-ordering failure. Plain depends_on (start order only) doesn't wait for readiness; healthcheck timeouts live in compose files, not the Dockerfile, and don't fix ordering; replicas and Swarm don't address the timing problem.

Q3. What is the primary purpose of the "docker build" command in containerization?

Explanation: The "docker build" command is used to create a new Docker image from a Dockerfile, which defines the instructions for building the image. This command is essential in containerization as it allows developers to package their applications and dependencies into a single container that can be easily deployed and managed.

Q4. What is the primary purpose of the .dockerignore file in a Docker containerization project?

Explanation: The .dockerignore file is used to specify files and directories that should not be included in the Docker image, improving build performance and reducing image size.

Q5. In a Docker Compose file, what is the correct syntax to define a container that uses the latest version of an image from Docker Hub?

Explanation: In a Docker Compose file, the correct syntax to define a container that uses the latest version of an image from Docker Hub is to use the format image: repository:tag, where repository is the name of the image and tag is the version. The correct syntax is image: nginx:latest, where nginx is the repository and latest is the tag.

Q6. Which of the following Dockerfile instructions is used to expose a container port for external access?

Explanation: The EXPOSE instruction in a Dockerfile is used to inform Docker which port to map from the container to the host during the container creation process. This allows external access to the container.

Q7. Which of the following Dockerfile instructions is used to expose a port in a Docker container?

Explanation: The EXPOSE instruction in a Dockerfile is used to inform the port that a container will listen on. It does not actually open the port, but rather informs the user and the Docker daemon about the port.

Q8. Which of the following Dockerfile instructions is used to set the working directory in a Docker container?

Explanation: The WORKDIR instruction sets the working directory in a Docker container. It is used to change the current working directory in the container to the specified path.

Q9. In Docker, what is the primary purpose of a Dockerfile?

Explanation: A Dockerfile is a text file that contains a set of instructions for building a Docker image. It specifies the base image, copies files into the image, sets environment variables, and more.

Q10. What is the primary benefit of using Dockerfiles in containerization?

Explanation: Dockerfiles are a text-based format for defining the instructions for building a Docker image. They allow developers to automate the process of building and deploying their applications, making it easier to manage and maintain their codebase.

That was just a sample. Sign up to unlock the full question bank with timed tests and certificates.

Sign Up Free
Containerization MCQ Practice Test | Mind Hustle