docker配置vpn拉取镜像

最近在做vulhub漏洞复现,本来有备用docker镜像的,没想到G了,只能配置vpn进行pull镜像。

大致思路

  1. 修改文件vim /etc/docker/daemon.json,配置docker官方镜像
bash 复制代码
{
 "registry-mirrors": [
    "https://hub.docker.com/"]
}
  1. 修改文件vim /etc/systemd/system/docker.service.d/proxy.conf
bash 复制代码
[Service]
Environment="HTTP_PROXY=http://<ip>:<port>"
Environment="HTTPS_PROXY=http://<ip>:<port>"

这里IP就是本机IP,端口就是代理端口

  1. 重启docker
bash 复制代码
# 加载配置
systemctl daemon-reload
# 重启docker
systemctl restart docker
# 查看代理配置是否生效
systemctl show --property=Environment docker
##---打印内容---
Environment=HTTP_PROXY=http://XXX:7892 HTTPS_PROXY=http://XXX:7892

非常重要的事情

一定要允许来自局域网的连接,我就是在这G了好久

几个错误

  1. 没有设置允许局域网连接就会出现以下错误:
bash 复制代码
Error response from daemon: Get "https://registry-1.docker.io/v2/": proxyconnect tcp: dial tcp xxx:xxx connect: connection refused
  1. /etc/docker/daemon.json文件格式错误会出现以下错误:
bash 复制代码
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
相关推荐
bukeyiwanshui5 分钟前
20260624 k8s pod命令
云原生·容器·kubernetes
wang_shu_mo_ran1 小时前
网络编程(一):网络编程初识
运维·服务器·网络
sukioe1 小时前
【无标题】
后端·docker·centos
姚青&2 小时前
持续交付与 DevOps 体系
运维·devops
ton_tom2 小时前
设备驱动程序编程-Linux2.6.10-kdb安装-32位
linux·运维·服务器
Elastic 中国社区官方博客2 小时前
谁来评判评判者?在 Elasticsearch Workflows 中使用 LLM-as-a-Judge
大数据·运维·人工智能·elasticsearch·搜索引擎·ai·全文检索
HAPPY酷3 小时前
【ROS2】VMware + Docker 运行 Gazebo 崩溃与“假死”排查实录
qt·docker·容器
SSO_Crown3 小时前
AI 招聘管理系统深度评测与选型指南
大数据·运维·人工智能
cft56200_ln3 小时前
gPTP Master 报文目的 MAC 地址
运维·服务器·网络
AOwhisky5 小时前
Linux(CentOS)系统管理入门笔记(第四期)——文件系统(下篇):文件与目录操作实战——cpmvmkdirrmln
linux·运维·笔记·centos·云计算·文件系统