Docker Tutorials

What is Docker?

Docker is a platform for developing, shipping, and running applications inside lightweight containers. Containers bundle your app with all its dependencies, ensuring it runs consistently across environments—from your local machine to production servers.

Installation & Setup

Install Docker Engine on Ubuntu and verify the service.

sudo apt update && sudo apt install -y docker.io
sudo systemctl status docker    # check Docker status
sudo systemctl enable --now docker # enable Docker if not running
docker --version    # check Docker version

Managing Images & Containers

Pull images, run containers, list and manage them.

docker pull nginx
docker run -d -p 8080:80 nginx    # start NGINX in background
docker ps -a       # list all containers
docker stop <container_id>    # stop a container
docker rm <container_id>      # remove a container

Dockerfile Basics

Define custom images with a Dockerfile.

FROM ubuntu:22.04
COPY . /app
RUN apt update && apt install -y python3
CMD ["python3", "/app/app.py"]
docker build -t myapp .    # build image
docker run myapp            # run built image

Docker Compose

Define and run multi-container applications.

version: '3'
services:
  web:
    image: nginx
    ports:
      - "8080:80"
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: example
docker-compose up -d          # start services
docker-compose logs -f        # follow logs
docker-compose down           # stop & remove containers

Volumes & Networking

Persist data and connect containers across networks.

docker volume create mydata
docker run -d -v mydata:/data nginx
docker network create mynet
docker run -d --network mynet --name web nginx