[Ubuntu 22.04] 安装docker,并设置镜像加速


for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

apt install -y curl vim wget gnupg dpkg apt-transport-https lsb-release ca-certificates

# 添加Docker的GPG公钥和apt源
#curl -sSL https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
#echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list

curl -sS https://download.docker.com/linux/debian/gpg | gpg --dearmor > /usr/share/keyrings/docker-ce.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu $(lsb_release -sc) stable" > /etc/apt/sources.list.d/docker.list

apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

docker version

tee /etc/docker/daemon.json << 'EOF'
{
    "registry-mirrors": [
        "http://hub-mirror.c.163.com",
        "https://mirror.baidubce.com",
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com",
        "https://dockerproxy.com",
        "https://ccr.ccs.tencentyun.com",
        "https://registry.cn-hangzhou.aliyuncs.com"
    ],
    "insecure-registries": ["192.168.11.20","192.168.11.30"]
}
EOF

systemctl restart docker.service

docker run hello-world

你可能感兴趣的:(Linux,ubuntu,docker,镜像源,22.04)