Doc
Start Service & Add User Group
sudo systemctl daemon-reload
sudo systemctl enable docker.service
sudo systemctl start docker
systemctl status docker
ls -alh /var/run/docker.sock
# craete login user
# sudo useradd -K UMASK=022 -g docker -m docker
# create non-login user
sudo useradd -M -s /usr/sbin/nologin -U docker
sudo usermod -a -G docker $USER
# relogin
id
docker version
CentOS - Docker 24.0
Install Docker Engine on CentOS
- Uninstall
rpm -qa | grep -E 'docker|container'
sudo yum rm docker-ce docker-ce-cli containerd.io
# yum -y erase docker-ce
# yum -y erase docker-ce-cli
# yum -y erase containerd.io
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
sudo rm /etc/docker/daemon.json
- Install
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum repolist && yum repolist
yum list docker-ce --showduplicates | sort -r | head
# specific version, e.g: 24.0
VERSION_STRING=$(dnf list docker-ce --showduplicates | grep docker | sort -k 2 -r | grep '24.0' | head -n 1 | awk '{print $2}' | awk -F':' '{print $2}') && echo $VERSION_STRING
sudo yum install docker-ce-$VERSION_STRING docker-ce-cli-$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
- Start Service & Add User Group
Debian - Docker 23.0
Install Docker Engine on Debian
- Uninstall
sudo apt autoremove
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt autoremove docker-ce docker-ce-cli
# sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker /var/lib/containerd
- Install
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
apt-cache madison docker-ce | awk '{ print $3 }'
# specific version, e.g: 23.0
apt-cache madison docker-ce | awk '{ print $3 }' | grep 5:2 | head
VERSION_STRING=5:23.0.4-1~debian.10~buster
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-buildx-plugin docker-compose-plugin
# latest
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Ubuntu - Docker 20.10
Install Docker Engine on Ubuntu
如何在 Ubuntu 20.04 上安裝和使用 Docker-阿里云開發(fā)者社區(qū)
Ubuntu 20.04下docker安裝和添加阿里云服務(wù)器鏡像和加速鏡像 - CodeAntenna
- Uninstall
# 移除容器褐鸥、鏡像、卷
docker container stop $(docker container ls -aq)
docker system prune -a --volumes
# 卸載軟件
sudo apt purge docker-ce
sudo apt autoremove
- Install
sudo apt update -y
sudo apt install -y software-properties-common apt-transport-https ca-certificates curl gnupg-agent
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
apt list -a docker-ce | grep '20.10' | head
VERSION=$(apt list -a docker-ce | grep '20.10'| head -2 | tail -1 | awk -F':' '{print $2}' | awk '{print $1}')
echo $VERSION
sudo apt install docker-ce=$VERSION docker-ce-cli=$VERSION containerd.io
systemctl status docker
cat /etc/docker/daemon.json
# Replace /etc/docker/daemon.json
sudo mkdir -p /etc/docker
sudo cat <<EOF > /etc/docker/daemon.json
{
"storage-driver": "overlay2",
"icc": true,
"iptables": true,
"log-driver": "json-file",
"log-opts": {
"max-size": "50m",
"max-file": "10",
"mode": "non-blocking"
},
"registry-mirrors": ["https://cu2yw19m.mirror.aliyuncs.com"],
"default-ulimits": {
"core": {
"Name": "core",
"Hard": 0,
"Soft": 0
}
}
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl enable docker
sudo usermod -a -G docker $USER
docker version
# 鎖住版本禁止自動更新
sudo apt-mark hold docker-ce
獲取鏡像加速器地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
Suse - Docker 19.03
- Uninstall
sudo zypper --non-interactive remove docker
sudo zypper --non-interactive remove runc containerd
- Install
Install Docker Engine on SLES
sudo zypper lr
sudo zypper ref
sudo zypper search -s --match-exact docker | sort -r | grep 19.03
sudo zypper install docker-19.03.15_ce-lp152.2.9.1.x86_64
# --non-interactive / -n
# docker-bash-completion-19.03.15_ce-lp152.2.9.1.noarch
sudo systemctl start docker.service
systemctl status docker.service
ls -alh /var/run/docker.sock
sudo usermod -a -G docker $USER
# relogin
docker version
Amazon Linux 2 - Docker 20.10
cat /etc/yum.repos.d/amzn2-core.repo
cat /etc/yum.repos.d/amzn2-extras.repo
yum search docker --show-duplicates
yum search docker --show-duplicates | grep '20.10'
sudo yum -y install docker-20.10*