Docker 修改镜像源地址

1. 直接设置 –registry-mirror 参数,仅对当前的命令有效

docker run hello-world --registry-mirror=https://docker.mirrors.ustc.edu.cn

修改 /etc/default/docker,加入 DOCKER_OPTS=”镜像地址”,可以有多个

DOCKER_OPTS="--registry-mirror=https://docker.mirrors.ustc.edu.cn"

2. 支持 systemctl 的系统

通过 sudo systemctl edit docker.service,会生成 etc/systemd/system/docker.service.d/override.conf 覆盖默认的参数,在该文件中加入如下内容:

[Service] ExecStart= ExecStart=/usr/bin/docker -d -H fd:// --registry-mirror=https://docker.mirrors.ustc.edu.cn

3. 新版的 Docker 推荐使用 json 配置文件的方式,

默认为 /etc/docker/daemon.json,非默认路径需要修改 dockerd 的 –config-file,在该文件中加入如下内容:

{
	"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

注:几个速度比较快的镜像地址

Docker 官方中国区: https://registry.docker-cn.com
网易: http://hub-mirror.c.163.com
中科大: https://docker.mirrors.ustc.edu.cn

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章