找回密码
 注册
查看: 1909|回复: 0

docker配置本地代理proxy

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-7-23 11:46:53 | 显示全部楼层 |阅读模式
[root@compute01 ~]# cat /etc/systemd/system/docker.service.d/proxy.conf
/ j' P$ s) P8 y) h+ L[Service]& j6 m8 N, D. |) p% X+ P  C
Environment="HTTP_PROXY=http://192.168.2.158:7890/"( l( r8 }/ S7 m
Environment="HTTPS_PROXY=http://192.168.2.158:7890/"
' ~& F- g, q) bEnvironment="NO_PROXY=localhost,127.0.0.1,.example.com"0 N( a- P( t$ a( J# Z/ @% [- N' r

' b7 T* g/ Q& {+ G重启docker服务生效: systemctl restart docker.service / I) b/ I+ L1 V7 X$ i, I
[root@compute01 ~]# docker info - U' p* t  K" Z% s& v
Client:/ F5 u# V+ a3 C- E  D! Y
Context:    default
6 @! L. C5 F5 b+ o. K1 }4 f" l Debug Mode: false
) n  o: D. M2 z1 w0 s Plugins:
  T, S+ h9 q; x  app: Docker App (Docker Inc., v0.9.1-beta3)! ~( ^* w+ [+ q2 W
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
$ R' {0 P9 O$ j$ D1 \  scan: Docker Scan (Docker Inc., v0.8.0)Server:4 t+ k5 c, c& O, X0 E  C
Containers: 0: X+ t) O4 f( \* v: z! W
  Running: 0" I8 \1 j8 o2 K6 Y
  Paused: 04 U5 t( p: Z1 R" [, i& z6 [
  Stopped: 0
5 f4 @7 E& ?& S Images: 0
3 G7 F4 ?7 e+ P) o" ~; k" f, {/ o Server Version: 20.10.7
: W2 ^7 n% A+ d& I# u6 q! j# f: C Storage Driver: overlay2
( T! {  @- ?+ Q' U( k% }  Backing Filesystem: xfs
5 @; F' l: o8 _# x6 I  Supports d_type: true
9 J6 |5 i2 t& v  Native Overlay Diff: true
; _4 @9 V: t; d9 S  userxattr: false* o6 s8 T6 f: B$ t
Logging Driver: json-file
, l! c; t) E, W, w Cgroup Driver: cgroupfs" w5 Z3 a2 L, {( z( j& F
Cgroup Version: 16 @/ c1 z1 y5 [  Q- k
Plugins:
4 D- h, [: g6 Q  Volume: local) @1 Q5 s" n* c# _0 j# {
  Network: bridge host ipvlan macvlan null overlay0 K, H5 ^; O( z9 M+ y
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
  s$ I( ]; N% R$ b) ] Swarm: inactive7 r! n* |! ~- V( e  ^/ k
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
; ~9 A  {1 w4 h  L, Y, Q7 k Default Runtime: runc2 }4 K- z2 O8 q  T% u
Init Binary: docker-init
- H, @* M" ?! U containerd version: 7eba5930496d9bbe375fdf71603e610ad737d2b27 C$ R5 k) n/ S; X% ^
runc version: v1.0.0-0-g84113ee
7 {* b' E  u/ M2 S* B: R9 m- n init version: de40ad0
6 L8 m; }/ E, ^( L0 F4 ?  j) J# m Security Options:. }8 B4 q% T& p9 W  R/ W1 m. t* h
  seccomp
% f3 q5 E+ E7 e4 ?; L) W. u   Profile: default
' a* i# Y) W% Q: v" l3 a1 o" ] Kernel Version: 3.10.0-1160.31.1.el7.x86_649 ^" ]* W! i' c0 |$ M
Operating System: CentOS Linux 7 (Core)3 w$ F: B* h. A: y# }& G' W% R
OSType: linux
( x5 Y. s, x& T. W5 a+ r% w% ~5 y- V8 } Architecture: x86_64
  N/ Q1 Q4 D- L% l% N, p7 ^ CPUs: 325 p, ^/ K* b( a4 J  y- `; V
Total Memory: 125.7GiB! i7 v9 ]% t' C# p  _
Name: compute013 Y, x& m. q% H: Q' S$ |# k
ID: AFW3:TFZH:XZUS:OH53:CCMW:WWK5:54TT:7QUV:TWQB:D3YZ:34HT:467T
( J# h! b7 F, t9 J" c- y" G Docker Root Dir: /var/lib/docker
7 f( m7 C3 q0 ?/ D Debug Mode: false0 o: ~+ U# W$ G- R
HTTP Proxy: http://192.168.2.158:7890/
# G2 k5 [2 Y' v9 q  s, B HTTPS Proxy: http://192.168.2.158:7890/
( g& I7 y0 A5 o" I. x No Proxy: localhost,127.0.0.1,.example.com
" \0 x3 [; C& L  m Registry: https://index.docker.io/v1/9 D- d8 I' F9 E+ c' g0 H/ H
Labels:7 ?3 w1 @6 k" T5 r
Experimental: false) A  x2 l( B( x" D( V  M5 Z
Insecure Registries:
$ o9 `8 J0 C+ r; w; Q  127.0.0.0/8% o: @7 o1 M9 `8 ]' y
Live Restore Enabled: false
+ Z$ e8 P) Y1 v& S3 @/ T
1 {8 {# u9 R# Q6 ?: t2 ?# s  Y4 ~
6 F/ C+ o) _$ C9 \* B- E; V9 m; S当不再使用时,我们需要取消这个代理:[root@compute01 ~]# cat /etc/systemd/system/docker.service.d/proxy.conf + ]9 z0 F/ E, j: T7 ^( m
#[Service]4 M- g; N3 m6 a9 u& m" h
#Environment="HTTP_PROXY=http://192.168.2.158:7890/"
8 q' B5 [( N6 O1 v#Environment="HTTPS_PROXY=http://192.168.2.158:7890/", H# W0 |" N8 `+ u; \7 v. j$ t! x
#Environment="NO_PROXY=localhost,127.0.0.1,.example.com"! [. G$ k2 y7 r" q

, n+ x6 U  ^7 ?+ E, t8 z重启docker服务:[root@compute01 ~]# systemctl daemon-reload systemctl restart docker.service
; e, v8 g7 c, W$ S- U& a
6 S, a8 {5 ^# X[root@compute01 ~]# docker info
: f, a" l: i4 L# Z, ZClient:
' O% [+ G1 H( H8 l( Q Context:    default- q5 o& F  u/ a+ n6 V6 s
Debug Mode: false9 h( @  v2 |' d
Plugins:
; J  F9 C1 [% c2 x- p+ Z6 c1 T  app: Docker App (Docker Inc., v0.9.1-beta3)
% d+ `$ Y9 P% M& W0 r  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
0 O4 D0 I3 Z9 e0 I7 @1 K  scan: Docker Scan (Docker Inc., v0.8.0)Server:
" V% B/ {) Y4 Z" E9 p! p Containers: 0
7 B$ C; x+ e; [/ ~2 O9 E  Running: 09 g: n6 q( M  e( f$ G
  Paused: 03 }) l; s- Y9 I5 B! S& x  }
  Stopped: 0
7 B: a1 |) C. T2 ] Images: 0
4 p! O3 L+ C" |+ i& f6 f Server Version: 20.10.7
7 U  O1 ^9 l7 Y Storage Driver: overlay2
: ?& t5 b! S5 ?1 p  Backing Filesystem: xfs# m5 W2 q6 `6 h* D% b. a1 B
  Supports d_type: true
) e6 Y3 J4 |5 P/ l# Q  Native Overlay Diff: true
; k: z1 x, H" N; s  userxattr: false6 g- k# i' L$ D. W1 A
Logging Driver: json-file
# O$ w) g$ W7 ?; H. H7 ~ Cgroup Driver: cgroupfs
, ?$ }* T- Y/ F7 x8 j# e. E2 E% x2 ^ Cgroup Version: 12 t) T. P* ?8 |5 Z/ S
Plugins:
" r5 B0 C4 I1 `$ v4 ]  Volume: local! t. Q9 U( L! {, B7 Y
  Network: bridge host ipvlan macvlan null overlay3 A- ^8 g9 \) V  C- e5 [7 a
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
/ F% @+ S. C& t4 A* s' [ Swarm: inactive! F% l2 U1 @6 o% z! T$ i. o5 }( ]
Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux3 y- s0 s  m0 d5 S+ E
Default Runtime: runc
. Z+ f/ y5 t  g& h0 O; [! X Init Binary: docker-init
+ H+ n5 E  V0 I- y containerd version: 7eba5930496d9bbe375fdf71603e610ad737d2b2
2 ?& S, e+ S- ]# N- E' O runc version: v1.0.0-0-g84113ee
  F, y- `, ]* x* x init version: de40ad0
6 w% K& {/ G; }  y5 B3 v Security Options:! o) q0 O  v8 J! t) P- N
  seccomp
( j7 A1 G6 {5 ~" Y! e   Profile: default0 O  M2 V8 r7 s$ ?! h7 a+ T3 _( R
Kernel Version: 3.10.0-1160.31.1.el7.x86_64$ R1 B7 H( G3 Z4 [
Operating System: CentOS Linux 7 (Core)
- f) |( |$ q4 w2 I6 z" y' d OSType: linux
8 ^3 o! ~2 P. G- c2 L: X Architecture: x86_64+ n) t7 q  g: N! l$ I0 A
CPUs: 32
% G; f* U; M3 j) _- c Total Memory: 125.7GiB
9 |, k1 l# v' `6 R1 H Name: compute01' S/ F8 z# K. {$ w$ ]% N
ID: AFW3:TFZH:XZUS:OH53:CCMW:WWK5:54TT:7QUV:TWQB:D3YZ:34HT:467T, |' \' t6 Z; L
Docker Root Dir: /var/lib/docker
/ X- r( o) H0 ~" U7 r Debug Mode: false4 o9 E& L' ~6 _& Y1 j6 a  g
Registry: https://index.docker.io/v1/
  s+ v& w0 U4 F3 s+ c Labels:4 \1 z6 x. ?/ o& E% j3 X; C
Experimental: false3 n/ V$ _; [( W+ R( I( X
Insecure Registries:
! D) Z3 d1 k" G  127.0.0.0/8
, l( ?- I+ N( N" {' P8 `+ P Live Restore Enabled: false$ z+ W! Q7 `! I) @( j2 F
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:30 , Processed in 0.016112 second(s), 23 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表