Back to roadmaps docker Course

Running Your First Container: Inside docker run

Let us run our first container and examine what Docker does behind the scenes.


1. Running the Container

Open your terminal and run:

docker run hello-world

2. Behind the Scenes: The Execution Flow

sequenceDiagram
    participant User
    participant CLI as Docker CLI
    participant Daemon as Docker Daemon
    participant Hub as Docker Hub

    User->>CLI: docker run hello-world
    CLI->>Daemon: Request to run 'hello-world'
    Note over Daemon: Check local image cache
    Daemon->>Daemon: Image not found locally
    Daemon->>Hub: Pull 'hello-world:latest'
    Hub-->>Daemon: Download image layers
    Daemon->>Daemon: Create container from image
    Daemon->>Daemon: Start container process
    Daemon-->>CLI: Stream output logs
    CLI-->>User: Display greeting message
  1. Local Check: The Docker Daemon checks if the hello-world image is stored locally.
  2. Registry Pull: Since the image is not found, the Daemon downloads it from Docker Hub.
  3. Container Creation: The Daemon creates a writeable container layer on top of the read-only image.
  4. Execution: The Daemon starts the container, runs the default greeting process, and streams the output to your terminal.
  5. Exit: The greeting process finishes, and the container stops.
Published on Last updated: