Cloud Native 21 min read

Master Docker: Install, Accelerate Images, and Manage Containers on Linux, Windows, and macOS

This comprehensive guide walks you through installing Docker on various operating systems, configuring image accelerators for faster pulls, and mastering Docker image management—including pulling, running, listing, filtering, and cleaning up images and containers—while addressing platform‑specific considerations.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Docker: Install, Accelerate Images, and Manage Containers on Linux, Windows, and macOS

This article provides a comprehensive guide to Docker images, covering installation on various operating systems, configuring image accelerators, and managing Docker images.

Install Docker

CentOS

Docker requires a kernel version higher than 3.10. Check the kernel version with: uname -r Update packages and remove old Docker versions:

sudo yum update
sudo yum remove docker docker-common docker-selinux docker-engine

Install required utilities:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

Set YUM repository

Official repo:

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Aliyun repo:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

Tsinghua repo:

sudo yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo

Install Docker

sudo yum install docker-ce

List available versions and install a specific one:

yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce-<version>.ce

Start Docker and enable on boot:

sudo systemctl start docker
sudo systemctl enable docker

Verify installation:

docker version

Ubuntu

System requirements

Docker CE supports Ubuntu 14.04 (Trusty), 16.04 (Xenial), and 17.10 (Artful). LTS versions are recommended for production.

Remove old versions

sudo apt-get remove docker \
    docker-engine \
    docker.io

Automatic installation script

curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror AzureChinaCloud

Start Docker:

sudo systemctl enable docker
sudo systemctl start docker

Docker Image Accelerator

To speed up image pulls in China, configure a registry mirror such as Docker's official China mirror, Alibaba Cloud, or DaoCloud. Example using Alibaba Cloud:

DOCKER_OPTS="--registry-mirror=https://xxxxxxxx.mirror.aliyuncs.com"

For systemd‑based systems, create /etc/docker/daemon.json:

{
  "registry-mirrors": [
    "https://xxxxxxxx.mirror.aliyuncs.com"
  ]
}

Restart Docker and verify with:

docker info

Docker Images

Pulling images

Use docker pull [options] [registry/][repository][:tag]. Example: docker pull ubuntu:16.04 The command shows layer IDs and the image digest.

Running containers

Run an interactive Bash shell from an image: docker run -it --rm ubuntu:16.04 bash Explanation of flags: -i (interactive), -t (tty), --rm (remove container after exit).

Listing images

Show downloaded images: docker image ls Columns include repository, tag, image ID, creation time, and size.

Dangling images

Images without a repository or tag appear as <none>. List them with: docker image ls -f dangling=true Remove them with:

docker image prune

Intermediate images

Use -a to list all images, including intermediate layers.

Filtering and formatting

Filter by repository, tag, or label, and format output with --format or -q for IDs only.

Removing images

Delete by ID, name, or digest:

docker image rm 501   # short ID
docker image rm centos # repository:tag
docker image rm node@sha256:...

When an image has multiple tags, Docker first un‑tags it; the image is deleted only after all tags are removed and no containers depend on it.

Important notes for CentOS/RHEL

CentOS/RHEL lack native UnionFS drivers, so Docker defaults to the devicemapper driver with loop‑lvm, which has performance and stability drawbacks. Configuring direct‑lvm for devicemapper is recommended.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerLinuxContainerInstallationImage Management
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

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.