当前位置: 首页 > news >正文

Docker配置代理

        有时候我们在使用docker下载镜像的时候可能想要配置代理区下载那么本文就给大家分享一下docker怎么配置代理。

        假设你已经有了代理,那就编辑/usr/lib/systemd/system/docker.service

        在[Service]下添加

Environment="HTTP_PROXY=http://127.0.0.1:6666/"
Environment="HTTPS_PROXY=http://127.0.0.1:6666/"
Environment="NO_PROXY=localhost,127.0.0.1"# HTTP_PROXY和HTTPS_PROXY填写代理地址
# NO_PROXY填写哪些地址不需要走代理
[root@bogon ~]# cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service containerd.service time-set.target
Wants=network-online.target containerd.service
Requires=docker.socket[Service]
Type=notify
Environment="HTTP_PROXY=http://127.0.0.1:6666/"
Environment="HTTPS_PROXY=http://127.0.0.1:6666/"
Environment="NO_PROXY=localhost,127.0.0.1"
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutStartSec=0
RestartSec=2
Restart=always# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Older systemd versions default to a LimitNOFILE of 1024:1024, which is insufficient for many
# applications including dockerd itself and will be inherited. Raise the hard limit, while
# preserving the soft limit for select(2).
LimitNOFILE=1024:524288# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes# kill only the docker process, not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500[Install]
WantedBy=multi-user.target

接下来重启服务即可

sudo systemctl daemon-reload
sudo systemctl restart docker

相关文章:

  • 【C语言】排序算法 -------- 计数排序
  • 课时158:脚本发布_简单脚本_远程执行
  • 线程相关的基本方法
  • 什么是内存泄漏?如何避免?
  • Android --- 异步操作
  • vscode插件开发之 - 消息通信
  • Apache HttpClient总览
  • QSS/QFrame/connect/两个窗口界面的连接/窗口的优化
  • DoIP——step2:车辆发现
  • 内网穿透的原理:实现远程访问的技术揭秘
  • Aeron:两个代理之间的单向IPC(One-way IPC between two agents)
  • visual studio下载安装
  • 【MySQL基础随缘更系列】AB复制
  • 你是否感受到AI就在身边?
  • Leetcode - 132双周赛
  • __proto__ 和 prototype的关系
  • 2017-09-12 前端日报
  • 345-反转字符串中的元音字母
  • Android 初级面试者拾遗(前台界面篇)之 Activity 和 Fragment
  • Git 使用集
  • gitlab-ci配置详解(一)
  • HashMap ConcurrentHashMap
  • Intervention/image 图片处理扩展包的安装和使用
  • JS 面试题总结
  • Linux学习笔记6-使用fdisk进行磁盘管理
  • Meteor的表单提交:Form
  • mongo索引构建
  • Mysql5.6主从复制
  • Netty 框架总结「ChannelHandler 及 EventLoop」
  • npx命令介绍
  • WinRAR存在严重的安全漏洞影响5亿用户
  • 等保2.0 | 几维安全发布等保检测、等保加固专版 加速企业等保合规
  • 第十八天-企业应用架构模式-基本模式
  • 关于Flux,Vuex,Redux的思考
  • 理解 C# 泛型接口中的协变与逆变(抗变)
  • 理清楚Vue的结构
  • 微服务入门【系列视频课程】
  • MPAndroidChart 教程:Y轴 YAxis
  • 阿里云移动端播放器高级功能介绍
  • 说说我为什么看好Spring Cloud Alibaba
  • ​一些不规范的GTID使用场景
  • # Pytorch 中可以直接调用的Loss Functions总结:
  • #设计模式#4.6 Flyweight(享元) 对象结构型模式
  • (1)Map集合 (2)异常机制 (3)File类 (4)I/O流
  • (4)logging(日志模块)
  • (转)用.Net的File控件上传文件的解决方案
  • ****Linux下Mysql的安装和配置
  • .htaccess配置重写url引擎
  • .NET MVC第五章、模型绑定获取表单数据
  • .net中生成excel后调整宽度
  • .NET中使用Redis (二)
  • .vue文件怎么使用_vue调试工具vue-devtools的安装
  • [ IOS ] iOS-控制器View的创建和生命周期
  • [1525]字符统计2 (哈希)SDUT
  • [240727] Qt Creator 14 发布 | AMD 推迟 Ryzen 9000芯片发布