SkillSprout
Chapter 1 · Lesson 3
Beginner
1 min read

Install Docker and Understand the First Run

Overview

Before running containers, verify that Docker is installed and that the Docker CLI can communicate with the Docker daemon. Docker Desktop includes a graphical application and Docker Engine on Windows and macOS. Linux distributions can install Docker Engine and supporting packages directly.

Detailed Notes

Verify the installation

bash
docker --version
docker version

docker --version prints the CLI version. docker version prints both the Client and Server sections. If the server section says it cannot connect, Docker Engine or Docker Desktop is not running, or the CLI cannot reach the daemon.

bash
docker run hello-world

Read this command from left to right:

  1. docker calls the Docker CLI.
  2. run asks Docker to create and start a container.
  3. hello-world names the image.

If the image is not cached, Docker pulls it from Docker Hub. The daemon creates a container with a writable layer. It starts the image's default command. The process prints a success message and exits. Docker keeps the stopped container until you remove it.

Common checks

bash
docker info
docker ps
docker ps -a
docker images
  • docker info summarizes daemon configuration.
  • docker ps shows running containers.
  • docker ps -a shows running and stopped containers.
  • docker images shows local image layers and tags.

Practice task

  1. Run docker run hello-world.
  2. Run docker ps; the container is expected to be absent because it exited.
  3. Run docker ps -a; locate the stopped hello-world container.
  4. Remove it with docker rm CONTAINER_NAME.
  5. Run docker images and locate hello-world.

Common Interview Questions

Finished this lesson?

0 of 27 lessons done · 0% of the course