Bird
Raised Fist0
Dockerdevops~10 mins

Container states (created, running, paused, stopped) in Docker - Step-by-Step Execution

Choose your learning style10 modes available
Process Flow - Container states (created, running, paused, stopped)
Container Created
↓
Container Running
↓
Paused
↓
Running
A container starts in 'created' state, then moves to 'running'. It can be paused and resumed back to running, or stopped to end.
Execution Sample
Docker
docker create alpine
docker start <container>
docker pause <container>
docker unpause <container>
docker stop <container>
Shows commands to create, start, pause, unpause, and stop a Docker container, changing its state step-by-step.
Process Table
StepCommandContainer State BeforeActionContainer State After
1docker create alpinenoneCreate containercreated
2docker start <container>createdStart containerrunning
3docker pause <container>runningPause containerpaused
4docker unpause <container>pausedResume containerrunning
5docker stop <container>runningStop containerstopped
💡 Container stopped, no further state changes without restart or removal.
Status Tracker
Container StateStartAfter Step 1After Step 2After Step 3After Step 4After Step 5
statenonecreatedrunningpausedrunningstopped
Key Moments - 3 Insights
Why can't we pause a container that is not running?
Because only a running container can be paused, as shown in step 3 where the state changes from running to paused. Pausing a non-running container is invalid.
What happens if we try to start a container that is already running?
Starting a running container has no effect; the state remains running as shown between steps 2 and 3.
Can a stopped container be resumed directly?
No, a stopped container must be started again to become running; unpause only works from paused state, not stopped.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the container state after step 3?
Apaused
Brunning
Cstopped
Dcreated
💡 Hint
Check the 'Container State After' column for step 3 in the execution table.
At which step does the container state change back to running after being paused?
AStep 5
BStep 2
CStep 4
DStep 1
💡 Hint
Look for the 'unpause' command and its effect in the execution table.
If we skip the pause command, what would be the container state after step 4?
Apaused
Brunning
Ccreated
Dstopped
💡 Hint
Refer to the variable_tracker to see state changes without pausing.
Concept Snapshot
Docker container states:
- created: container exists but not running
- running: container is active
- paused: container temporarily frozen
- stopped: container halted
Use 'docker start', 'pause', 'unpause', 'stop' to change states.
Full Transcript
This visual execution shows how Docker container states change step-by-step. First, a container is created (state: created). Then it is started and becomes running. From running, it can be paused, freezing its processes. Unpausing resumes running. Finally, stopping the container ends it, moving to stopped state. Each command changes the container state as shown in the execution table and variable tracker. Understanding these states helps manage container lifecycle effectively.

Practice

(1/5)
1. Which Docker container state means the container is currently executing processes?
easy
A. stopped
B. created
C. paused
D. running

Solution

  1. Step 1: Understand container states

    The 'running' state means the container is actively executing its processes.
  2. Step 2: Compare other states

    'Created' means container is made but not started, 'paused' means temporarily halted, 'stopped' means container is not running.
  3. Final Answer:

    running -> Option D
  4. Quick Check:

    Active container = running [OK]
Hint: Running means container is actively working [OK]
Common Mistakes:
  • Confusing 'created' with 'running'
  • Thinking 'paused' means running
  • Mixing 'stopped' with 'running'
2. Which command shows all Docker containers including stopped ones?
easy
A. docker ps -a
B. docker pause
C. docker start
D. docker ps

Solution

  1. Step 1: Recall docker ps usage

    'docker ps' shows only running containers by default.
  2. Step 2: Use option to show all containers

    'docker ps -a' lists all containers, including stopped and paused ones.
  3. Final Answer:

    docker ps -a -> Option A
  4. Quick Check:

    Show all containers = docker ps -a [OK]
Hint: Add -a to see all containers, not just running [OK]
Common Mistakes:
  • Using 'docker ps' alone shows only running containers
  • Confusing 'docker start' with listing containers
  • Thinking 'docker pause' lists containers
3. What is the state of the container after running these commands?
docker create nginx
docker start <container_id>
docker pause <container_id>
medium
A. paused
B. created
C. running
D. stopped

Solution

  1. Step 1: Analyze commands sequence

    'docker create' makes container in 'created' state, 'docker start' moves it to 'running'.
  2. Step 2: Effect of 'docker pause'

    'docker pause' suspends container processes without stopping it, changing state to 'paused'.
  3. Final Answer:

    paused -> Option A
  4. Quick Check:

    Pause command sets state to paused [OK]
Hint: Pause command changes running to paused state [OK]
Common Mistakes:
  • Assuming container stays running after pause
  • Confusing created with paused
  • Thinking pause stops the container
4. You ran docker pause mycontainer but got an error saying container is not running. What is the likely cause?
medium
A. Container is already paused
B. Container is stopped or not started
C. Container name is incorrect
D. Docker daemon is not running

Solution

  1. Step 1: Understand pause command requirements

    'docker pause' only works on running containers to suspend them temporarily.
  2. Step 2: Interpret error message

    Error about container not running means it is stopped or never started, so pause cannot apply.
  3. Final Answer:

    Container is stopped or not started -> Option B
  4. Quick Check:

    Pause needs running container [OK]
Hint: Pause only works on running containers [OK]
Common Mistakes:
  • Trying to pause stopped containers
  • Ignoring container state before pausing
  • Assuming pause works on any container
5. You want to temporarily stop a container without losing its state and then resume it later. Which sequence of commands should you use?
hard
A. docker kill <container_id> then docker start <container_id>
B. docker stop <container_id> then docker start <container_id>
C. docker pause <container_id> then docker unpause <container_id>
D. docker restart <container_id> then docker pause <container_id>

Solution

  1. Step 1: Understand stopping vs pausing

    'docker stop' stops container and loses running state; 'docker pause' suspends without stopping.
  2. Step 2: Identify commands to pause and resume

    'docker pause' suspends container, 'docker unpause' resumes it preserving state.
  3. Final Answer:

    docker pause & docker unpause -> Option C
  4. Quick Check:

    Pause/unpause = temporary stop and resume [OK]
Hint: Pause to stop temporarily, unpause to resume [OK]
Common Mistakes:
  • Using stop loses container state
  • Confusing kill with pause
  • Restarting instead of unpausing
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard