Skip to Content

How Docker Works — Images, Containers, Volumes

How Docker Works

Images, Containers, and Volumes — the three core concepts

Docker has only three concepts you need to understand. Once you grasp images, containers, and volumes, everything else is just details. Let us walk through each one.

Images — The Blueprints

A Docker image is a read-only template that contains everything needed to run a piece of software: the operating system, libraries, application code, and configuration. Think of it as a snapshot or a recipe.

Downloading images
docker pull postgres:16
docker pull odoo:18

Docker Hub

Docker Hub is the public registry where thousands of pre-built images are available. PostgreSQL, Nginx, Python, Node.js — all ready to use.

Containers — The Running Instances

A container is a running instance of an image. You can start, stop, restart, and delete containers without affecting the image. Multiple containers can run from the same image simultaneously.

Starting containers
docker run -d --name my-postgres postgres:16
docker run -d --name my-odoo odoo:18

Lightweight

Containers share the host OS kernel. Starting a container takes seconds, not minutes like a virtual machine.

Isolated

Each container has its own filesystem, network, and process space. One container cannot interfere with another.

Disposable

Containers are meant to be created and destroyed. If something breaks, delete and recreate it from the image.

Volumes — Persistent Storage

By default, data inside a container is lost when the container is deleted. Volumes solve this by storing data outside the container on the host machine. Your database files, uploaded images, and configuration survive container restarts and updates.

Using volumes
docker volume create pgdata
docker run -d -v pgdata:/var/lib/postgresql/data postgres:16

Never Skip Volumes

Without volumes, deleting a database container means losing all your data. Always use volumes for any data you want to keep.

How They Work Together

1

Pull an image

Download a pre-built image from Docker Hub or build your own from a Dockerfile.

2

Create a container

Start a new container from the image. Map ports and attach volumes.

3

Attach volumes

Connect named volumes to directories inside the container for persistent storage.

4

Run your service

The container starts the application. It is isolated, portable, and reproducible.

Remember

Image is the recipe, container is the running dish, volume is the pantry that survives between cooking sessions. Master these three concepts and Docker becomes simple.

Hlubší prozkoumání Docker konceptů včetně image, kontejnerů, volumes, Docker Hubu a klíčových příkazů, které budete v kurzu používat.

Rating
0 0

There are no comments for now.

to be the first to leave a comment.