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.
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-engineInstall required utilities:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2Set YUM repository
Official repo:
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repoAliyun repo:
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoTsinghua repo:
sudo yum-config-manager --add-repo https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repoInstall Docker
sudo yum install docker-ceList available versions and install a specific one:
yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce-<version>.ceStart Docker and enable on boot:
sudo systemctl start docker
sudo systemctl enable dockerVerify installation:
docker versionUbuntu
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.ioAutomatic installation script
curl -fsSL get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror AzureChinaCloudStart Docker:
sudo systemctl enable docker
sudo systemctl start dockerDocker 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 infoDocker 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 pruneIntermediate 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
