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-world2. 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- Local Check: The Docker Daemon checks if the
hello-worldimage is stored locally. - Registry Pull: Since the image is not found, the Daemon downloads it from Docker Hub.
- Container Creation: The Daemon creates a writeable container layer on top of the read-only image.
- Execution: The Daemon starts the container, runs the default greeting process, and streams the output to your terminal.
- Exit: The greeting process finishes, and the container stops.
Published on Last updated: