Ubuntu18及以上发行版安装docker

Table of Contents
sudo apt update -y && sudo apt upgrade -y && sudo apt full-upgrade && sudo apt autoremove -y
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo systemctl status docker
sudo systemctl enable docker
sudo docker version
# 参考的docker服务配置文件
cat <<'EOF' | sudo tee /etc/docker/daemon.json
{
  "data-root": "/mnt/data/docker",
  "registry-mirrors": [ "https://0728759bfb8025910ffe278y38c77800.mirror.swr.myhuaweicloud.com" ],
  "exec-opts": ["native.cgroupdriver=systemd"],
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "100m"
  },
  "storage-driver": "overlay2"
}
EOF
sudo systemctl restart docker
sudo systemctl status docker

参考文档

https://linux.cn/article-14871-1.html

Posted in env