Operations 36 min read

Comprehensive Docker Tutorial: Installation, Image Management, Networking, Compose, and Registry

This article provides a detailed Docker tutorial covering container fundamentals, installation steps, basic commands, image lifecycle, volume handling, Dockerfile creation, image layering, Zabbix deployment, private registry setup, Docker‑Compose orchestration, networking modes, and best‑practice recommendations for container operations.

Top Architect
Top Architect
Top Architect
Comprehensive Docker Tutorial: Installation, Image Management, Networking, Compose, and Registry

The guide begins with an overview of Linux containers, explaining their isolation, portability, and differences from traditional virtualization.

1. What is Docker?

Docker is introduced as a containerization platform that leverages Linux kernel features such as cgroups and namespaces to build, ship, and run applications across environments.

1.1 Docker Architecture

Details on Docker’s client‑server model, image‑based deployment, and the benefits of layered images are provided.

2. Installing Docker

# yum install -y yum-utils device-mapper-persistent-data lvm2
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# yum install docker-ce docker-ce-cli containerd.io

Configuration adjustments for remote API access and daemon reload are also shown.

3. Basic Docker Commands

# docker version
# docker run -d -p 80:80 nginx
# docker ps -a
# docker stop
# docker rm

4. Image Management

# docker pull centos
# docker tag centos:latest myregistry.local/centos:1.0
# docker push myregistry.local/centos:1.0
# docker rmi centos:latest

Commands for searching, pulling, tagging, exporting, importing, and inspecting images are included.

5. Container Lifecycle

# docker run -it --name mycentos centos /bin/bash
# docker exec -it mycentos /bin/bash
# docker commit mycentos mycentos:custom
# docker start mycentos
# docker rm -f $(docker ps -a -q)

Explanation of container start/stop, interactive mode, and the importance of keeping the main process running.

6. Data Volumes

# docker run -d -p 80:80 -v /data/www:/usr/share/nginx/html nginx
# docker volume create mydata
# docker run -d -v mydata:/app/data myimage

Shows how to create, mount, and inspect volumes, emphasizing persistence and sharing data between containers.

7. Dockerfile and Image Building

FROM centos:6.8
RUN yum install -y openssh-server && echo "root:123456" | chpasswd
CMD ["/usr/sbin/sshd","-D"]

Instructions for writing Dockerfiles, using directives like FROM, RUN, CMD, ADD, COPY, ENV, and building images with docker build -t myimage .

8. Image Layering

Explains how each Dockerfile instruction creates a new read‑only layer, how layers are shared among images, and the copy‑on‑write mechanism for container writes.

9. Deploying Services (e.g., Zabbix)

# docker run --name mysql-server -e MYSQL_ROOT_PASSWORD=root_pwd -d mysql:5.7
# docker run --name zabbix-server -p 10051:10051 --link mysql-server:mysql -d zabbix/zabbix-server-mysql

Shows linking containers and exposing ports for service communication.

10. Private Registry

# docker run -d -p 5000:5000 --restart=always --name registry -v /opt/registry:/var/lib/registry registry:2
# docker login myregistry.local:5000
# docker push myregistry.local:5000/myimage:tag

Includes steps for basic and basic‑auth protected registries.

11. Docker‑Compose

version: '3'
services:
  db:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: pwd
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    environment:
      WORDPRESS_DB_HOST: db:3306

Demonstrates multi‑container orchestration, scaling, and service definitions.

12. Networking Modes

Describes bridge, host, none, container, and macvlan networks, with examples of creating custom bridge networks and assigning static IPs using pipework .

13. Best Practices

Do not use the latest tag in production.

Avoid large monolithic images; keep them small and layered.

Run a single process per container and use non‑root users.

Store data in volumes, not inside containers.

References to official Docker documentation and additional resources are provided at the end.

DockerDevOpsnetworkingContainersDocker ComposeImage ManagementRegistry
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.