• Discover
  • Collections
  • Board
  • Create
  • Profile
  • Settings
Paths

Lesson 3: Docker Images and Registries

Lesson 3: Docker Images and Registries

3 min read

Introduction

In the previous lesson, we ran our first container using the hello-world image. But what exactly is a Docker image, and where do they come from? This lesson dives deep into the concept of Docker images, explaining their structure, how they relate to containers, and the role of registries like Docker Hub in distributing them. Understanding images is crucial for building and deploying your own applications with Docker.

Key Concepts

What is a Docker Image?

A Docker Image is a lightweight, standalone, executable package that includes everything needed to run a piece of software, including the code, a runtime, libraries, environment variables, and config files. Images are read-only templates used to create containers. They are built up from a series of layers, where each layer represents a modification to the image, such as installing a package or adding a file.

  • Read-Only Nature: Images are immutable once created. When you make changes, a new layer is added.

  • Layering: This allows for efficiency. If multiple images share common base layers, those layers are only stored once, saving disk space.

Docker Registries: Docker Hub

A Docker Registry is a repository for Docker images. It's a place where you can store your Docker images, making them accessible to others or to your own systems for deployment.

  • Docker Hub: The most popular public registry. It hosts millions of public and private images. You can find official images for popular software (e.g., Ubuntu, Nginx, Node.js) and images contributed by the community.

  • Private Registries: Organizations often use private registries (e.g., Azure Container Registry, Amazon ECR, GitLab Container Registry) to store their proprietary images securely.

Image Tags

Images often have tags to denote different versions, variants, or specific builds.

For example, `ubuntu:

latestrefers to the latest stable version of the Ubuntu image, whileubuntu:

  1. 04refers to a specific version. If no tag is specified when pulling an image (e.g.,docker pull ubuntu), Docker defaults to the latest` tag.

Example/Code

Pulling and Inspecting Images

To pull a specific version of an image:

bash
docker pull nginx:1.21.6

To list local images and see their IDs, tags, and sizes:

bash
docker images

To get detailed information about a specific image, including its layers and configuration:

bash
docker inspect nginx:1.21.6

Summary/Key Takeaways

  • Docker images are immutable, layered templates containing everything an application needs to run.

  • Docker registries, like Docker Hub, are central repositories for storing and sharing images.

  • Images use tags to denote versions or specific configurations.

  • docker pull downloads images, docker images lists them, and docker inspect provides detailed metadata.

End of lesson
👏Well done!
Previous Lesson
Lesson 2: Installing Docker and Basic Commands
Next Lesson
Lesson 4: Running Containers and Port Mapping

Course Content

0% Complete0/20 Lessons

Lesson 1: Introduction to Containers and Docker

Lesson 2: Installing Docker and Basic Commands

Lesson 3: Docker Images and Registries

Lesson 4: Running Containers and Port Mapping

Quiz

Course Content

0% Complete0/20 Lessons

Lesson 1: Introduction to Containers and Docker

Lesson 2: Installing Docker and Basic Commands

Lesson 3: Docker Images and Registries

Lesson 4: Running Containers and Port Mapping

Quiz