docker正确配置腾讯云镜像地址
如默
撰写于 2024年 06月 06 日

说明

腾讯软件源官网给的配置教程有误,配置完成之后还是显示无法连接,切换了一下方式才成功,记录一下。

官网文档

附上官网文档地址:腾讯云修改docker镜像文档

附上腾讯云软件源官网:腾讯软件源

下面是详细步骤,Ubuntu系统:

# 打开配置文件
vim /etc/default/docker

# 添加以下内容
DOCKER_OPTS="--registry-mirror=https://mirror.ccs.tencentyun.com"

CentOS7系统:

# 打开配置文件
vim /etc/docker/daemon.json

# 添加以下内容
{
   "registry-mirrors": [
   "https://mirror.ccs.tencentyun.com"
  ]
}

修改完配置文件,重启一下docker

systemctl daemon-reload
systemctl restart docker

验证

执行

docker info

输出的内容最后三行有这个就表示配置成功:

 Registry Mirrors:
  https://mirror.ccs.tencentyun.com/
 Live Restore Enabled: false

补充

我的系统是Ubuntu22.04,但是按照Ubuntu系统那样配置没生效,而且,那个配置文件默认是有内容的,只需要把注释符号删掉修改一下就可以了,即第14行,原始内容如下:

# Docker SysVinit configuration file

#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
#   Please see the documentation for "systemd drop-ins":
#   https://docs.docker.com/engine/admin/systemd/
#

# Customize location of Docker binary (especially for development testing).
#DOCKERD="/usr/local/bin/dockerd"

# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"

# This is also a handy place to tweak where Docker's temporary files go.
#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp"

但我换成CentOS那样的配置文件就生效了,所以我查看了一下上面文件里的docker官方文档,文档显示,这个文件是配置docker守护进程的,需要添加一个守护进程,而守护进程使用的配置文件就是这个/etc/docker/daemon.json,所以腾讯云的文档不太严谨,可能是没有更新,官网写的docker23.0以上都是这样。以后还是建议查看docker官网文档。配置守护进程验证如下:

sudo systemctl show --property=Environment docker

Environment=HTTP_PROXY=http://proxy.example.com:3128 HTTPS_PROXY=https://proxy.example.com:3129 NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp

相应的配置文件如下:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:3128"
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"

文件路径为:/etc/systemd/system/docker.service.d/http-proxy.conf

docker正确配置腾讯云镜像地址

说明

腾讯软件源官网给的配置教程有误,配置完成之后还是显示无法连接,切换了一下方式才成功,记录一下。

官网文档

附上官网文档地址:腾讯云修改docker镜像文档

附上腾讯云软件源官网:腾讯软件源

下面是详细步骤,Ubuntu系统:

# 打开配置文件
vim /etc/default/docker

# 添加以下内容
DOCKER_OPTS="--registry-mirror=https://mirror.ccs.tencentyun.com"

CentOS7系统:

# 打开配置文件
vim /etc/docker/daemon.json

# 添加以下内容
{
   "registry-mirrors": [
   "https://mirror.ccs.tencentyun.com"
  ]
}

修改完配置文件,重启一下docker

systemctl daemon-reload
systemctl restart docker

验证

执行

docker info

输出的内容最后三行有这个就表示配置成功:

 Registry Mirrors:
  https://mirror.ccs.tencentyun.com/
 Live Restore Enabled: false

补充

我的系统是Ubuntu22.04,但是按照Ubuntu系统那样配置没生效,而且,那个配置文件默认是有内容的,只需要把注释符号删掉修改一下就可以了,即第14行,原始内容如下:

# Docker SysVinit configuration file

#
# THIS FILE DOES NOT APPLY TO SYSTEMD
#
#   Please see the documentation for "systemd drop-ins":
#   https://docs.docker.com/engine/admin/systemd/
#

# Customize location of Docker binary (especially for development testing).
#DOCKERD="/usr/local/bin/dockerd"

# Use DOCKER_OPTS to modify the daemon startup options.
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"

# If you need Docker to use an HTTP proxy, it can also be specified here.
#export http_proxy="http://127.0.0.1:3128/"

# This is also a handy place to tweak where Docker's temporary files go.
#export DOCKER_TMPDIR="/mnt/bigdrive/docker-tmp"

但我换成CentOS那样的配置文件就生效了,所以我查看了一下上面文件里的docker官方文档,文档显示,这个文件是配置docker守护进程的,需要添加一个守护进程,而守护进程使用的配置文件就是这个/etc/docker/daemon.json,所以腾讯云的文档不太严谨,可能是没有更新,官网写的docker23.0以上都是这样。以后还是建议查看docker官网文档。配置守护进程验证如下:

sudo systemctl show --property=Environment docker

Environment=HTTP_PROXY=http://proxy.example.com:3128 HTTPS_PROXY=https://proxy.example.com:3129 NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp

相应的配置文件如下:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:3128"
Environment="HTTPS_PROXY=https://proxy.example.com:3129"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"

文件路径为:/etc/systemd/system/docker.service.d/http-proxy.conf


赞 (0)

猜您想看

  • Magic Trackpad使用体验(Windows11 和 Mac OS13.2)

    如题,我购买了apple的Magic Trackpad和一台Mac Mini,但是后者预计发货时间在月底,可秒控板首先到了,没有Mac,不能测试触控板吗?幸好,我在全球最大的同性交友网站上找到了相关驱动,记录一下。

    2023年02月19日
  • Ubuntu安装nodejs

    如题,记录在Ubuntu安装nodejs过程

    2023年04月27日
  • Windows10 1903版更新体验

    前一阵子太忙了,各种乱七八糟的事情,以及新备案了一个网站(某个莫名其妙的项目),所以网站关闭了好一阵子。 草稿很多,但是都没有完善,今天水一篇。

    2019年06月12日
  • Windows 11正式版发布,官方原版ISO下载以及使用体验

    Windows 11正式版发布,记录一下官方原版ISO下载以及使用体验

    2021年10月07日
  • Mindoc编译安装指南(Linux版)

    mindoc文档系统想做一些修改,就必须使用源码进行安装,在网上找了很多教程,都没有使用源代码进行安装,遂做一个记录。

    2019年03月12日
  • 阿斯加特 ddr5 6400M 32G*2套条体验

    最近因为玩天际线2,想升级到64G内存,购买了阿斯加特 ddr5 6400M 32G*2套条,但是问题很多,记录一下。

    2024年02月18日

评论区(2条评论)

我要评论

Vaptcha 初始化中...

萧瑟
LV1
  

今天拉镜像贼卡,刚需,感谢分享

如默
博主
   萧瑟

就是,最近很卡