Install Docker
Install Docker on Ubuntu / CentOS — configure the Aliyun mirror, verify the version, and start the systemd service
Docker is an open-source containerization platform for developing, shipping, and running applications. It packages an application and its dependencies into a lightweight, portable container that runs in any Docker-compatible environment — delivering on the "build once, run anywhere" promise.
Installation
# Step 1: install required system tools
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
# Step 2: trust Docker's GPG public key
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Step 3: write the package source
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Step 4: install Docker
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-pluginInstall a specific version of Docker-CE
# 1. List available versions
apt-cache madison docker-ce
# docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://mirrors.aliyun.com/docker-ce/linux/ubuntu xenial/stable amd64 Packages
# 2. Install a specific version (VERSION example: 17.03.1~ce-0~ubuntu-xenial)
sudo apt-get -y install docker-ce=[VERSION]# Step 1: install required system tools
sudo yum install -y yum-utils
# Step 2: add the package source
yum-config-manager --add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: install Docker
sudo yum install docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-pluginInstall a specific version of Docker-CE
# 1. List available versions
yum list docker-ce.x86_64 --showduplicates | sort -r
# docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
# docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
# 2. Install a specific version (VERSION example: 17.03.0.ce.1-1.el7.centos)
sudo yum -y install docker-ce-[VERSION]To enable the testing repository, edit /etc/yum.repos.d/docker-ce.repo and change enabled=0 under the [docker-ce-test] section to enabled=1.
Verify the installation
docker versionExample of a successful output:
Client: Docker Engine - Community
Version: 26.0.0
API version: 1.45
Go version: go1.21.8
Git commit: 2ae903e
Built: Wed Mar 20 15:21:09 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 26.1.0
API version: 1.45 (minimum version 1.24)
Go version: go1.21.9
Git commit: c8af8eb
Built: Mon Apr 22 17:08:46 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0Start Docker
sudo systemctl start docker
sudo systemctl enable dockerCheck the service status
sudo systemctl status dockerExample of a healthy output:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2024-10-29 18:21:24 CST; 1 months 17 days ago
Docs: https://docs.docker.com
Main PID: 20454 (dockerd)
Tasks: 208
Memory: 7.5G
CGroup: /system.slice/docker.service
└─20454 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sockLast updated on
Was this page helpful?
