5 exercises — Master the English vocabulary of the container lifecycle: state transitions, restart policies, OOM kills, health check states, and exit codes.
0 / 27 completed
1 / 27
A developer runs docker ps -a and asks a teammate: "Walk me through the full container lifecycle — what states can a container be in and in what order?"
Which sequence correctly describes the Docker container state flow?
The Docker container lifecycle states are:
• created — the container has been created (docker create) but not started
• running — the main process (ENTRYPOINT/CMD) is executing; the container is alive
• paused — processes are suspended via SIGSTOP (docker pause); memory is preserved but CPU is not consumed
• exited (stopped) — the main process has terminated; container metadata and filesystem still exist until docker rm
• dead — Docker could not properly stop or remove the container; a rare error state requiring manual cleanup
docker ps shows only running containers. docker ps -a shows containers in all states including exited. A container must be explicitly removed with docker rm to free all resources.
Key vocabulary:
• container state — the current lifecycle phase (created / running / paused / exited / dead)
• exited — a stopped container whose main process has terminated; metadata persists until removed
• docker ps -a — lists all containers including stopped ones; without -a, shows only running containers
• docker rm — removes a stopped container and frees its filesystem and metadata
2 / 27
An engineer asks: "Our PostgreSQL container must automatically restart after a crash or Docker daemon restart, but it should not restart when we run docker stop for planned maintenance. Which restart policy fits?"
unless-stopped combines crash recovery with respect for deliberate maintenance stops.
Docker restart policies:
• no (default) — never restart automatically
• always — always restart, even after docker stop and even after Docker daemon restart
• on-failure[:max-retries] — restart only when the exit code is non-zero (a crash); clean exits and deliberate stops are not retried
• unless-stopped — restart on crash or daemon restart, but NOT if the container was deliberately stopped with docker stop
For a production database, unless-stopped is the right choice: it survives crashes and host reboots, but allows operators to run maintenance windows by simply stopping the container — it won't bounce back automatically until manually started again.
Key vocabulary:
• restart policy — a Docker container setting controlling automatic restart behaviour
• unless-stopped — restart always except after a deliberate docker stop
• on-failure — restart only on non-zero exit codes (crashes)
• always — restart regardless of how the container stopped
• maintenance window — a planned period where a service is deliberately taken offline for updates or repair
3 / 27
An on-call alert fires. The container log shows: "Container api-server exited with code 137. Node recorded an oomkill event in kernel logs."
What does exit code 137 indicate?
Exit code 137 = 128 + SIGKILL (9) — the process was force-killed, most often by the OOM killer.
Linux exit codes for signal-killed processes follow the convention: 128 + signal_number.
• SIGKILL = signal 9, so 128 + 9 = 137
• SIGTERM = signal 15, so 128 + 15 = 143
The OOM (Out-Of-Memory) killer is the Linux kernel component that sends SIGKILL to processes when overall or cgroup memory is exhausted. In Docker, if a container's process exceeds its --memory limit, the kernel OOM-kills it and Docker reports exit code 137.
Resolution: increase the memory limit, fix a memory leak in the application, or add memory profiling to understand the growth.
Key vocabulary:
• exit code 137 — 128 + SIGKILL (9); process was force-killed, typically by the OOM killer
• OOM killer — the Linux kernel mechanism that kills memory-hungry processes to prevent system collapse
• SIGKILL — signal 9; unconditional kill that cannot be caught or ignored by the process
• memory limit — the --memory container flag setting the cgroup memory ceiling
• cgroup — Linux control group; enforces resource limits (memory, CPU) for container processes
4 / 27
A Docker Swarm service shows 1/1 replicas 0 running even though the container process is running. docker inspect shows "Health": "unhealthy".
What happens when a container's health check reports unhealthy in Docker Swarm?
Docker health check states:
• starting — within the initial grace period; health check results don't count yet
• healthy — the health check command is passing
• unhealthy — the health check has failed --retries consecutive times
In plain Docker (no orchestration): the container stays running but is marked unhealthy in docker ps. Docker itself takes no corrective action — you must intervene.
In Docker Swarm: the Swarm manager detects unhealthy tasks and schedules replacements to maintain the desired replica count. In Kubernetes, a failing liveness probe triggers a pod restart. This automated healing is the primary reason orchestration is used for production workloads.
Key vocabulary:
• health check — a periodic command Docker executes inside a running container to assess application health
• starting — the health check grace period; failures during this phase don't count toward unhealthy
• healthy / unhealthy — the passing and failing health check states
• liveness probe — Kubernetes equivalent of a Docker health check; triggers pod restart on failure
• self-healing — an orchestrator's ability to automatically replace failed containers to maintain desired state
5 / 27
Four engineers each describe why their container exited. Which description correctly maps all four common exit codes?
Linux exit code rules:
• 0 — success; the process completed normally
• 1 — general application error; the most common non-zero exit for app bugs or config errors
• 137 — 128 + 9 (SIGKILL); force-killed by the OOM killer or docker kill
• 143 — 128 + 15 (SIGTERM); the process received SIGTERM (from docker stop) and exited
The docker stop workflow: Docker sends SIGTERM to PID 1 → waits for the grace period (default 10 s) → if the process hasn't exited, sends SIGKILL. A well-behaved container catches SIGTERM, completes in-flight work, and exits with code 143. An unresponsive container gets SIGKILL'd and exits with code 137.
Key vocabulary:
• exit code — an integer returned by a process when it terminates; 0 = success, non-zero = failure or signal
• SIGTERM — signal 15; polite shutdown request from docker stop; catchable by the application
• SIGKILL — signal 9; forceful, uncatchable kill; sent after grace period expires
• graceful shutdown — catching SIGTERM, draining in-flight requests, then exiting cleanly
• PID 1 — the first process in the container; must handle signals correctly for clean shutdowns
6 / 27
Sarah: 'Hey team, I've just deployed a new version of the payment-processor container. The CI/CD pipeline built and pushed an image to our registry, but the containers aren't starting correctly. I'm seeing errors in the deployment logs – it seems like they're stuck in a Pending state. Can someone explain what might be happening and what steps we should take?'
Which of the following best describes the initial stages of a container's lifecycle when a new image is deployed, based on common Docker practices?
Containers don't start directly after deployment; they first need to pull the image from the registry. This initial stage is represented as Pending – Docker is actively downloading the new image layers. Only after the image has been successfully pulled and the container's configuration is applied does it transition into a Running state, ready to execute its processes. It's crucial to understand this pull-and-configure sequence, as issues here are frequently the root cause of deployment problems.
7 / 27
Liam: 'Okay team, we've just deployed the new version of our user-service container. I ran docker pull and then docker run, but the container is stuck in a 'Created' state and hasn't started yet. It's like it's waiting for something. Any ideas?'
Initially, when you run docker run after pulling an image, Docker doesn't immediately start the container. It goes through several stages: it first creates the container (indicated by 'Created'), then performs a health check to ensure the application inside is running correctly and ready to serve requests. This health check can take some time, especially if it involves network connectivity or initial data setup – so 'Created' represents this preparatory phase before the actual process starts.
8 / 27
During a new container image deployment, the 'Pending' state is frequently encountered. Let's consider what happens immediately after pulling an image from a registry and attempting to run it with `docker run`.
John: 'I just ran docker pull my-registry/user-service:v2 and then docker run -d --name user-service my-registry/user-service:v2. It's stuck in Pending! What's going on?'
The 'Pending' state signifies that Docker hasn't yet allocated resources to the container. This typically happens when the Docker daemon needs to perform tasks like setting up networking, allocating memory, or performing other initial setup actions before the container can actually start running. Option A accurately reflects this process; options B, C, and D misrepresent the cause of a 'Pending' state.
9 / 27
Sarah: 'Hey team, I've just deployed a new version of the payment-processor container. The CI/CD pipeline built and pushed an image to our registry, but the containers aren't starting correctly. I'm seeing errors in the deployment logs – it seems like they're stuck in a Pending state. Can someone explain what might be happening and what steps we should take?'
Which of the following best describes the initial stages of a container's lifecycle when a new image is deployed, based on common Docker practices?
Containers don't start directly after deployment; they first need to pull the image from the registry. This initial stage is represented as Pending – Docker is actively downloading the new image layers. Only after the image has been successfully pulled and the container's configuration is applied does it transition into a Running state, ready to execute its processes. It's crucial to understand this pull-and-configure sequence, as issues here are frequently the root cause of deployment problems.
10 / 27
Liam: 'Okay team, we've just deployed the new version of our user-service container. I ran docker pull and then docker run, but the container is stuck in a 'Created' state and hasn't started yet. It's like it's waiting for something. Any ideas?'
Initially, when you run docker run after pulling an image, Docker doesn't immediately start the container. It goes through several stages: it first creates the container (indicated by 'Created'), then performs a health check to ensure the application inside is running correctly and ready to serve requests. This health check can take some time, especially if it involves network connectivity or initial data setup – so 'Created' represents this preparatory phase before the actual process starts.
11 / 27
During a new container image deployment, the 'Pending' state is frequently encountered. Let's consider what happens immediately after pulling an image from a registry and attempting to run it with `docker run`.
John: 'I just ran docker pull my-registry/user-service:v2 and then docker run -d --name user-service my-registry/user-service:v2. It's stuck in Pending! What's going on?'
The 'Pending' state signifies that Docker hasn't yet allocated resources to the container. This typically happens when the Docker daemon needs to perform tasks like setting up networking, allocating memory, or performing other initial setup actions before the container can actually start running. Option A accurately reflects this process; options B, C, and D misrepresent the cause of a 'Pending' state.
12 / 27
Sarah: 'Hey team, I've just deployed a new version of the payment-processor container. The CI/CD pipeline built and pushed an image to our registry, but the containers aren't starting correctly. I'm seeing errors in the deployment logs – it seems like they're stuck in a Pending state. Can someone explain what might be happening and what steps we should take?'
Which of the following best describes the initial stages of a container's lifecycle when a new image is deployed, based on common Docker practices?
Containers don't start directly after deployment; they first need to pull the image from the registry. This initial stage is represented as Pending – Docker is actively downloading the new image layers. Only after the image has been successfully pulled and the container's configuration is applied does it transition into a Running state, ready to execute its processes. It's crucial to understand this pull-and-configure sequence, as issues here are frequently the root cause of deployment problems.
13 / 27
Liam: 'Okay team, we've just deployed the new version of our user-service container. I ran docker pull and then docker run, but the container is stuck in a 'Created' state and hasn't started yet. It's like it's waiting for something. Any ideas?'
Initially, when you run docker run after pulling an image, Docker doesn't immediately start the container. It goes through several stages: it first creates the container (indicated by 'Created'), then performs a health check to ensure the application inside is running correctly and ready to serve requests. This health check can take some time, especially if it involves network connectivity or initial data setup – so 'Created' represents this preparatory phase before the actual process starts.
14 / 27
During a new container image deployment, the 'Pending' state is frequently encountered. Let's consider what happens immediately after pulling an image from a registry and attempting to run it with `docker run`.
John: 'I just ran docker pull my-registry/user-service:v2 and then docker run -d --name user-service my-registry/user-service:v2. It's stuck in Pending! What's going on?'
The 'Pending' state signifies that Docker hasn't yet allocated resources to the container. This typically happens when the Docker daemon needs to perform tasks like setting up networking, allocating memory, or performing other initial setup actions before the container can actually start running. Option A accurately reflects this process; options B, C, and D misrepresent the cause of a 'Pending' state.
15 / 27
Sarah: 'Hey team, I've just deployed a new version of the payment-processor container. The CI/CD pipeline built and pushed an image to our registry, but the containers aren't starting correctly. I'm seeing errors in the deployment logs – it seems like they're stuck in a Pending state. Can someone explain what might be happening and what steps we should take?'
Which of the following best describes the initial stages of a container's lifecycle when a new image is deployed, based on common Docker practices?
Containers don't start directly after deployment; they first need to pull the image from the registry. This initial stage is represented as Pending – Docker is actively downloading the new image layers. Only after the image has been successfully pulled and the container's configuration is applied does it transition into a Running state, ready to execute its processes. It's crucial to understand this pull-and-configure sequence, as issues here are frequently the root cause of deployment problems.
16 / 27
Liam: 'Okay team, we've just deployed the new version of our user-service container. I ran docker pull and then docker run, but the container is stuck in a 'Created' state and hasn't started yet. It's like it's waiting for something. Any ideas?'
Initially, when you run docker run after pulling an image, Docker doesn't immediately start the container. It goes through several stages: it first creates the container (indicated by 'Created'), then performs a health check to ensure the application inside is running correctly and ready to serve requests. This health check can take some time, especially if it involves network connectivity or initial data setup – so 'Created' represents this preparatory phase before the actual process starts.
17 / 27
During a new container image deployment, the 'Pending' state is frequently encountered. Let's consider what happens immediately after pulling an image from a registry and attempting to run it with `docker run`.
John: 'I just ran docker pull my-registry/user-service:v2 and then docker run -d --name user-service my-registry/user-service:v2. It's stuck in Pending! What's going on?'
The 'Pending' state signifies that Docker hasn't yet allocated resources to the container. This typically happens when the Docker daemon needs to perform tasks like setting up networking, allocating memory, or performing other initial setup actions before the container can actually start running. Option A accurately reflects this process; options B, C, and D misrepresent the cause of a 'Pending' state.
18 / 27
Code Review Comment: 'The container logs show a `SIGSEV` signal. This usually indicates a serious hardware problem like an I/O error or memory issue. It's not directly related to the application code itself. We need to investigate the host machine's health and resource usage.' What is the primary focus of this comment?
This question tests understanding of a critical error signal. The comment correctly focuses on diagnosing the *host* machine as the source of the problem, rather than assuming application code is at fault. It's crucial to differentiate between application-level and infrastructure problems when debugging containers.
19 / 27
Alex: 'I'm seeing a lot of `docker logs` showing 'Error connecting to database' for my microservice. It seems like the container can't reach the database server. I've checked network connectivity from within the container, and it appears fine. What could be causing this problem?'
Which response is most appropriate for David to send in a Slack channel?
Alex describes a common problem – connectivity issues. The most helpful response is to direct Alex towards investigating the *other* endpoint (the database) as that's where the issue likely resides. Simply restarting the database may not solve the underlying network configuration problems.
20 / 27
PR Description: 'Updated the container image to include the latest security patches and resolved a minor performance bottleneck. The deployment process was automated via Jenkins, and all tests passed successfully before pushing the new image to Docker Hub.'
Which sentence best summarizes the key information presented in this PR description?
A good PR description should concisely communicate *what* changed. This response accurately captures the core elements: image updates, automation (Jenkins), and successful testing – all crucial aspects of a deployment. It's not just about the process; it's about the changes made within the container.
21 / 27
Ben: 'During yesterday's deployment of the new version of our analytics-processor container, we encountered a 'Pending' state frequently. After pulling the image from Docker Hub and running `docker run`, the containers remained stuck in this state for approximately 15 minutes before finally starting.'
What is Ben most likely trying to communicate during his standup update?
Ben's description of the 'Pending' state and subsequent delay strongly suggests an issue with either the image pull process or the container's startup. These are common causes for containers remaining in a non-running state after deployment – it's a critical piece of information to share during a standup.
22 / 27
You're troubleshooting a container that consistently fails its health check. The container is running application code, and the health check periodically probes a specific HTTP endpoint. After reviewing the logs, you find that the endpoint returns a 503 (Service Unavailable) error intermittently. What's the most probable reason for this?
A 503 error indicates that the service is temporarily unavailable. Given the context of a health check probing an HTTP endpoint, it's almost certainly the application code *within* the container itself experiencing transient issues or downtime – the most common cause for this scenario.
23 / 27
Maria is investigating a container that's stuck in the 'Created' state after deployment. She ran `docker inspect` on the container and observed a large amount of time spent waiting for an event. What's the most likely reason?
Containers in the 'Created' state indicate that Docker has successfully pulled the image but hasn't yet started the process. This often happens when the container isn't automatically linked to a network or if there are dependencies missing. Incorrect image tags will also cause this behavior as Docker attempts to pull a different version.
24 / 27
During a standup meeting, David explains that his team deployed a new container for their API service. After running `docker run`, the containers are consistently showing 'Error: Connection refused' when trying to access them from other services. What's the most probable cause?
David: 'We just pushed the updated image to our registry and ran it with docker run, but…'
This scenario strongly suggests a networking issue. Containers often need explicit network configuration to be accessible from outside their isolated environment. A 'Connection refused' error indicates that the container isn't listening on any port or the firewall rules aren't permitting connections.
25 / 27
You are reviewing a PR description for a new container deployment. The description states: 'The CI/CD pipeline built and pushed an image to our registry, but the containers aren't starting correctly. I'm seeing errors in the logs related to missing environment variables.' Which action should you recommend?
PR Description: 'Updated the container image...'
The PR description clearly points to a missing environment variable. The CI/CD pipeline is responsible for configuring the container, so it's crucial to verify that all required variables are being passed correctly during the build and deployment process. Restarting or rebooting won't fix the root cause.
26 / 27
Sarah is troubleshooting a container that's stuck in the 'Pending' state after deploying a new version. She examines the Docker events and sees an error: 'Container create failed.' What's the most likely reason?
Sarah: 'Hey team, I've just deployed...'
A 'Container create failed' event typically indicates a resource constraint. Containers require CPU and memory to run, and if these resources are exhausted before the container starts, Docker will report this failure. Incorrect image tags can also cause failures but usually result in different error messages.
27 / 27
Liam is observing a situation where his user-service container consistently fails its health check after deployment. The health check probes a specific HTTP endpoint. What's the most likely explanation?
Liam: 'Okay team, we've just deployed...'
A failing health check usually indicates an issue with the application itself – it's not responding to the probe correctly. This could be due to a bug in the code or a misconfiguration that prevents the endpoint from being accessible. The other options are potential causes for general container issues, but less directly related to a failing health check.
What does the "Container Lifecycle Language" exercise practise?
Practice container lifecycle vocabulary in English: state transitions, restart policies, OOM kill, health check states, and exit codes 0/1/137/143. 5 intermediate exercises.
How many questions are in this exercise?
This exercise has 27 questions, each multiple-choice with a full explanation shown after you answer.
What English level is this exercise for?
This exercise is tagged Intermediate. If the vocabulary feels difficult, browse the Containers & Virtualization category page for an easier module to start with.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free with no account, sign-up, or paywall.
Do I get feedback if I answer incorrectly?
Yes — whichever option you choose, right or wrong, you'll immediately see an explanation clarifying the correct term and why the other options don't fit.
Can I retry this exercise?
Yes — once you finish all the questions, a "Try again" button on the results screen resets the exercise so you can practise as many times as you like.
Do I need an account to track my progress?
No account is required. Your progress bar and score for this session are tracked in the browser as you go, but nothing is saved once you leave the page.
Is "Container Lifecycle Language" part of a larger series?
Yes — it's one exercise in the Containers & Virtualization category on CoderSlingo. See the category page for the full list of related exercises on similar terminology.
Can I link directly to this exercise?
Yes — this exercise has its own permanent URL, so you can bookmark it or share the link directly with a colleague or study partner.
Where can I find more exercises like this one?
See the Containers & Virtualization category page for related exercises, or browse the main Exercises hub for other IT English topics.