Cloud Native 45 min read

Comprehensive Docker Guide: Installation, Core Commands, Dockerfile, and Docker Compose

This article provides a comprehensive guide to Docker, covering its core concepts, installation steps for CentOS, macOS, and Windows, essential Docker commands, detailed Dockerfile instructions, and an introduction to Docker Compose with practical examples.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Comprehensive Docker Guide: Installation, Core Commands, Dockerfile, and Docker Compose

Docker is an open‑source container engine that packages applications and their dependencies into lightweight, portable containers, ensuring consistent behavior across development, testing, and production environments.

Installation steps are detailed for three major platforms: on CentOS you remove old versions, install required yum utilities, configure the repository and install the Docker Engine; on macOS you can install Docker Desktop via Homebrew ( brew install --cask docker ) or download the installer manually; on Windows you download Docker Desktop, enable WSL 2/Hyper‑V, and run the installer.

Key Docker service commands include systemctl start|stop|restart docker and docker-compose up -d for orchestrating multi‑container applications. Image management uses docker pull , docker build -t name:tag . , docker images , and docker rmi . Container lifecycle commands cover docker run , docker ps , docker stop , docker start , docker exec -it , and docker rm .

The Dockerfile section explains the most common instructions: FROM to set the base image, LABEL for metadata, RUN to execute commands during build, CMD and ENTRYPOINT to define the container’s default command, ENV for environment variables, COPY / ADD for files, WORKDIR , EXPOSE , VOLUME , USER , ARG , ONBUILD , STOPSIGNAL , and HEALTHCHECK . Example Dockerfiles for a Python Flask app, a Node.js app, and an Nginx static site illustrate practical usage.

Docker Compose is introduced as a tool to define and run multi‑container applications using a docker-compose.yml file. The file’s main sections— version , services , networks , and volumes —are described, with a complete WordPress‑MySQL example showing service definitions, environment variables, port mappings, dependencies, and custom networks.

Common Docker Compose commands are listed: docker-compose up -d to start services, docker-compose down to stop and clean up, docker-compose ps to view status, docker-compose logs -f for real‑time logs, docker-compose build to rebuild images, and docker-compose restart to restart services.

References to official Docker documentation, Docker Hub, and several tutorial resources are provided for further reading.

DockerDevOpsContainerizationDockerfileDocker Compose
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

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.