Containers & Images Questions with Answers

20 practice questions on Containers & Images (DevOps & Kubernetes) with answers and step-by-step solutions. Try 10 samples below, then practise all 20 free in the AptiNest app.

Sample questions

Question 1Easy

A container image vs a container:

  1. An image is a template; a container is a running instance
  2. An image is created each time you run a container with the --rm flag set
  3. A container is stored in a registry; an image runs on a host
  4. They are two names for the same thing

Answer: A. An image is a template; a container is a running instance

Explanation

You build and push images; you run containers from them, each with its own writable layer.

Step-by-step solution

  1. An image is a static file with all necessary code and libraries.
  2. A container is the running process based on that image.
  3. Images are used to create containers.
  4. Containers can run multiple instances of an image.
  5. Each container has its own writable layer.

Why the other options are wrong

  • B. An image is not built on each run; the --rm flag only removes the container when it stops.
  • C. This swaps the two: images are stored in registries and run as containers on a host, not the reverse.
  • D. They are not the same: an image is the static template, and a container is one running copy of it.

Tip: Remember: images are static, containers are dynamic.

Question 2Easy

A container stops by itself as soon as it starts. The most common reason is:

  1. Containers always stop after one minute unless a volume is mounted
  2. Its main process (PID 1) exited
  3. The registry went offline
  4. The image is too large

Answer: B. Its main process (PID 1) exited

Explanation

A container lives only as long as its main process; if the command finishes or crashes, the container exits.

Step-by-step solution

  1. A container lives as long as its main process.
  2. If PID 1 exits, the container stops.
  3. A common cause is a command that finishes immediately.

Why the other options are wrong

  • A. There is no one-minute rule.
  • C. The registry is not needed after pull.
  • D. Image size does not stop it.

Tip: PID 1 exits, container stops.

Question 3Easy

docker run -p 8080:80 nginx means:

  1. Host port 8080 forwards to container port 80
  2. The container gets 8080 MB of memory
  3. Host port 80 forwards to container port 8080
  4. Nginx serves 80 requests per 8080 ms at most

Answer: A. Host port 8080 forwards to container port 80

Explanation

The -p flag is host:container.

Step-by-step solution

  1. -p host:container maps ports.
  2. 8080 is the host port.
  3. 80 is the container port.

Why the other options are wrong

  • B. It is not memory.
  • C. The order is reversed.
  • D. It is not a rate limit.

Tip: host:container.

Question 4Easy

What is Docker Compose typically used for?

  1. Building VM images
  2. Scheduling containers across a production cluster of hundreds of nodes
  3. Scanning images for vulnerabilities
  4. Defining and running multi-container apps locally from one file

Answer: D. Defining and running multi-container apps locally from one file

Explanation

A compose file describes services, networks and volumes so a whole stack starts with one command.

Step-by-step solution

  1. Docker Compose manages multiple containers together.
  2. It uses a single file to define all services.
  3. This allows running complex apps locally easily.
  4. The correct answer is Defining and running multi-container apps locally from one file.

Why the other options are wrong

  • A. Compose does not build VM images; it defines and runs containers from a single file.
  • B. Compose runs on one host for local work and is not a cluster scheduler for hundreds of nodes.
  • C. Scanning images for vulnerabilities is a job for separate security tools, not for Docker Compose.

Tip: Use Docker Compose for local app development with one command.

Question 5Medium

Which Linux kernel features give containers isolation and resource limits?

  1. The bootloader and swap partition, configured per container
  2. SELinux alone, with no other features
  3. Namespaces for isolation and cgroups for limits
  4. Systemd units and cron jobs

Answer: C. Namespaces for isolation and cgroups for limits

Explanation

Namespaces isolate PIDs, network, mounts and more; control groups cap CPU, memory and I/O.

Step-by-step solution

  1. Containers are processes on the host that are separated by kernel features.
  2. Namespaces give each container its own view of PIDs, network, mounts and more, which gives isolation.
  3. Control groups (cgroups) cap CPU, memory and I/O, which gives resource limits.
  4. The correct answer is option C, namespaces for isolation and cgroups for limits.

Why the other options are wrong

  • A. The bootloader and swap partition are not container isolation or limit features.
  • B. SELinux is a security policy layer; on its own it gives neither isolation nor resource limits.
  • D. Systemd units and cron jobs manage services and schedules, not container isolation.

Tip: Containers = namespaces (what a process can see) + cgroups (how much it can use).

Question 6Medium

Why can a container built on an Apple Silicon (ARM) laptop fail on an x86 server?

  1. The registry strips ARM images during every push unless signed
  2. x86 servers do not support Linux namespaces
  3. The image's binaries target the wrong CPU architecture
  4. Containers cannot run on servers

Answer: C. The image's binaries target the wrong CPU architecture

Explanation

Images are architecture-specific; build multi-platform images (e.g. linux/amd64 and linux/arm64) to run on both.

Step-by-step solution

  1. ARM and x86 are different architectures.
  2. Binaries compiled for one cannot run on the other.
  3. The image targets the wrong CPU.

Why the other options are wrong

  • A. Registries do not strip ARM images.
  • B. x86 supports namespaces.
  • D. Containers run on servers.

Tip: Match the CPU architecture.

Question 7Medium

Why is deploying the ':latest' tag in production risky?

  1. It is always the oldest image in the repository
  2. It is mutable, so the same tag can mean different images over time
  3. Registries delete latest images after a day
  4. Kubernetes refuses to run images tagged latest under any circumstances

Answer: B. It is mutable, so the same tag can mean different images over time

Explanation

Tags can be moved; pin a specific version tag or an immutable digest so deploys are reproducible.

Step-by-step solution

  1. The ':latest' tag points to the most recent image pushed to the registry.
  2. This tag can change over time as new images are uploaded.
  3. Using ':latest' means deploying a potentially different image each time.
  4. This makes deployments unpredictable and hard to reproduce.
  5. Therefore, ':latest' is mutable and not reliable for production use.

Why the other options are wrong

  • A. The latest tag is not the oldest image; it points to the most recently pushed image.
  • C. Registries do not delete latest images after a day; the tag stays unless someone moves it.
  • D. Kubernetes does not refuse the latest tag; the risk is that the tag can point to different images over time.

Tip: Always pin exact image versions in production, never use ':latest'.

Question 8Medium

OCI (Open Container Initiative) standards matter because they:

  1. Replace the need for a registry
  2. Let images built by one tool run on other compliant runtimes
  3. Make containers into virtual machines
  4. Define the pricing of container hosting across cloud vendors

Answer: B. Let images built by one tool run on other compliant runtimes

Explanation

Standard image and runtime specs keep images portable across Docker, containerd, Podman and Kubernetes.

Step-by-step solution

  1. OCI standards ensure images work with different runtimes.
  2. Images built by one tool can run on other compliant systems.
  3. This portability is key for interoperability between tools.
  4. It allows seamless use across Docker, containerd, and Podman.
  5. Thus, OCI standards enable runtime compatibility.

Why the other options are wrong

  • A. OCI standards do not replace registries; they define image and runtime formats that registries store.
  • C. OCI standards do not turn containers into virtual machines; containers still share the host kernel.
  • D. Pricing of cloud container hosting is set by vendors and is not something OCI standards define.

Tip: Remember OCI makes containers work everywhere by setting universal standards.

Question 9Hard

Running a container with --privileged is discouraged because:

  1. It disables networking
  2. It makes the container read-only
  3. It gives the container near-full access to the host
  4. It doubles the container's memory limit for every process inside it

Answer: C. It gives the container near-full access to the host

Explanation

Privileged mode lifts most isolation, so a compromise of the container can easily become a host compromise.

Step-by-step solution

  1. Privileged mode removes container restrictions.
  2. Container gains access to host hardware and processes.
  3. This allows full control over the host system.
  4. Container can modify files and settings on the host.
  5. Container can run any process with root privileges.
  6. Final answer: It gives the container near-full access to the host.

Why the other options are wrong

  • A. Privileged does not disable networking; the container keeps its network but gains much wider host access.
  • B. A privileged container is not made read-only; it usually gets more write access to the host, not less.
  • D. Privileged mode does not double the memory limit; memory limits are set separately and stay in force.

Tip: Avoid --privileged unless absolutely necessary for security.

Question 10Hard

A container exits with code 137. What does this usually indicate?

  1. It was killed with SIGKILL, often by the out-of-memory killer
  2. The image could not be pulled
  3. The entrypoint file was not executable
  4. It completed successfully

Answer: A. It was killed with SIGKILL, often by the out-of-memory killer

Explanation

Exit codes above 128 mean 'killed by signal (code − 128)': 137 − 128 = 9, SIGKILL, commonly from hitting a memory limit.

Step-by-step solution

  1. Exit code 137 is above 128, meaning it was killed by a signal.
  2. Subtract 128 from 137 to find the signal number: 137 − 128 = 9.
  3. Signal 9 is SIGKILL, which often happens when memory limits are exceeded.
  4. SIGKILL is usually triggered by the out-of-memory killer in Linux.
  5. This indicates the container was killed due to running out of memory.

Why the other options are wrong

  • B. An image pull failure shows as an ImagePull error, not as exit code 137 from a running container.
  • C. A non-executable entrypoint fails with a permission error, not with the SIGKILL signal behind code 137.
  • D. Exit code 0 means success; 137 is above 128, so it reports a signal kill, not a clean finish.

Tip: Remember: exit code 137 = SIGKILL due to out-of-memory killer.

Practise all 20 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all DevOps & Kubernetes topics · All topics