docker pull 错误

发布时间 2023-10-31 00:50:57作者: mcayear

情况如下

root@ser761626334371:~# docker run -p 5140:5140 -v /opt/koishi/data:/koishi -e TZ=Asia/Shanghai koishijs/koishi
Unable to find image 'koishijs/koishi:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp 127.0.0.1:7890: connect: connection refused.
See 'docker run --help'.

当docker拉取一个容器镜像时,会失败并提示代理错误 127.0.0.1:7890

一开始

我使用

export http_proxy="http://127.0.0.1:7890"
export https_proxy="http://127.0.0.1:7890"

来添加系统环境变量,但后来我想退坑代理。于是我便碰上了这个错误。

首先,正常取消系统环境变量

unset http_proxy
unset https_proxy

重新执行 docker 命令发现依旧报错。

我们继续执行

systemctl cat docker

获取到 docker 配置文件路径后修改

vim /lib/systemd/system/docker.service

删掉 HTTP_PROXY 与 HTTPS_PROXY 两行内容。

最后重启服务

sudo systemctl daemon-reload
systemctl restart docker