Docker Tutorial for Beginners – Learn Docker, Dockerfile Tutorial & Docker Compose

Keywords: docker tutorial, docker basics, learn docker, dockerfile tutorial, docker compose tutorial, docker containers

Start here: Watch the Docker tutorial below — then follow the step-by-step guide.

Docker Tutorial Summary & Core Concepts

Docker helps you build images and run containers consistently across environments — ideal for beginners learning the docker basics and anyone who wants a practical docker guide.

Core Concepts (docker container basics)

Install Docker (Windows)

  1. Download and install Docker Desktop.
  2. Verify installation:
    docker --version
  3. Open VS Code and install the Docker extension.

Work with Docker (learn docker)

Dockerfile Tutorial & Example (dockerfile example)

Your Dockerfile defines how to build an image.

# Base image: Node.js v22
FROM node:22
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ENV PORT=9000
EXPOSE 9000
CMD ["npm","start"]

How to build a Docker image (docker build image)

docker build -t test .

-t sets the tag/name; . uses the current folder.

How to run a Docker container (how to run docker)

docker run -p 9000:9000 test

-p maps a host port to the container port.

Debugging

In Docker Desktop select the container and check Logs, open a Terminal, or view Stats.

Docker Compose Tutorial (docker compose up)

If your app has multiple parts (backend + database), manage them together with Docker Compose.

Container application with backend and database

Typical Problems

Solution: compose.yaml

services:
  backend:
    build: .
    ports:
      - '9000:9000'
  db:
    image: postgres:latest
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: mydb
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

Compose Commands

docker compose up
docker compose down

Docker Build Cloud

Quickstart

docker init

Docker scaffolds the necessary files (Dockerfile, compose file).

Get the README + Image (ZIP)

Prefer the complete Markdown version including the example image? Download below!

Want to convert the Markdown file into another format? Use one of our online converters: