文章

国内一键安装docker/compose并替换国内dockerHub镜像源

1.国内一键安装Docker脚本

sudo curl -sSL https://get.daocloud.io/docker | sh 

2.替换docker hub镜像

sudo vim /etc/docker/daemon.json

上面的命令有daemon.json 文件就会编辑,没有就会创建,然后添加如下内容

{
  "registry-mirrors": ["https://docker.1panel.live/",
    "https://1ms.run/",
    "https://docker.xuanyuan.me/",
    "https://dev.xuanyuan.dev/",
    "https://dytt.online/",
    "https://docker.zyjs8.com/",
    "https://lispy.org/",
    "https://docker-0.unsee.tech/",
    "https://gh.123822.xyz",
    "https://docker.m.daocloud.io",
    "https://dockerproxy.net",
    "https://demo.52013120.xyz",
    "https://proxy.vvvv.ee",
    "https://xdark.top/",
    "https://registry.cyou/",
    "https://mirror.ccs.tencentyun.com"
  ]
}

3.重新启动 Docker Daemon 并查看信息

sudo systemctl daemon-reload
sudo systemctl restart docker
docker info

一些其他的源:

DaoCloud

https://docker.m.daocloud.io

"https://docker.1panel.live/", "https://docker.zyjs8.com/",
"https://1ms.run/",
"https://docker.xuanyuan.me/",
"https://dev.xuanyuan.dev/",
"https://dytt.online/",
"https://lispy.org/",
"https://docker-0.unsee.tech/",
"https://gh.123822.xyz",
"https://docker.m.daocloud.io",
"https://dockerproxy.net",
"https://demo.52013120.xyz",
"https://proxy.vvvv.ee",
"https://xdark.top/",
"https://registry.cyou/", "https://mirror.ccs.tencentyun.com"

4.docker-compose.yml替换源

注意image填写改为添加前缀docker.m.daocloud.io 一般就可以了

services:
  db:
    image: docker.m.daocloud.io/postgres  
    restart: always
    container_name: postgres
    environment:
      POSTGRES_PASSWORD: sample20241020
      POSTGRES_USER: sample
      TZ: Asia/Shanghai
    ports:
      - 5432:5432
    volumes:
      - /root/postgres/db:/var/lib/postgresql/data

许可协议:  CC BY 4.0