Skip to content

Instantly share code, notes, and snippets.

@lewangdev
Last active July 2, 2024 02:31
Show Gist options
  • Save lewangdev/0e382d118ceb9f5f12934eddfb6ba2b1 to your computer and use it in GitHub Desktop.
Save lewangdev/0e382d118ceb9f5f12934eddfb6ba2b1 to your computer and use it in GitHub Desktop.
在阿里云中国大陆机房的Debian系统上安装Docker服务和拉取dockerhub镜像

安装 docker-ce

# https://developer.aliyun.com/article/110806
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc


echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.aliyun.com/docker-ce/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get -y install docker-ce

配置 dockerhub 镜像

搭建 dockerhub 镜像参考这里 使用 cloudflare + registry 自建 dockerhub 镜像服务

# 配置使用自定义镜像
sudo tee /etc/docker/daemon.json <<EOF​
{
  "registry-mirrors": [
    "https://your_dockerhub_mirror.com"
  ]
}
EOF

# 重启docker服务,使配置生效
sudo systemctl restart docker

试试修改有没有成功

出现以下信息就说明成功了

root@devlab:/etc/docker# docker pull hello-world​
Using default tag: latest​
latest: Pulling from library/hello-world​
c1ec31eb5944: Pull complete​
Digest: sha256:266b191e926f65542fa8daaec01a192c4d292bff79426f47300a046e1bc576fd​
Status: Downloaded newer image for hello-world:latest​
docker.io/library/hello-world:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment