|
|
[root@compute01 ~]# cat /etc/systemd/system/docker.service.d/proxy.conf
2 s% s5 z1 y, f& O% ?[Service]
# c& m( [. {- bEnvironment="HTTP_PROXY=http://192.168.2.158:7890/"* k, i4 b3 B' Y+ k
Environment="HTTPS_PROXY=http://192.168.2.158:7890/") O. v$ ~( E7 e! C) m; e/ ?* ~' G
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
$ z! j1 k3 B" C6 s% K: j; E/ b/ N# z6 x/ {& a- H" ?# J
重启docker服务生效: systemctl restart docker.service
, |: Y7 |+ l8 D$ ?[root@compute01 ~]# docker info 2 h- w! o4 q. }7 U
Client:+ r# d" y1 O% `+ o
Context: default
# b( G6 K y& V- m5 i0 Q! } Debug Mode: false# |. ^! c# g, W4 d4 L$ n
Plugins:7 v8 V7 t0 ] _' a, Y9 @
app: Docker App (Docker Inc., v0.9.1-beta3)' L$ S/ H2 }) A* \1 Y
buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)9 h4 P9 O( Y& o9 k4 y' y
scan: Docker Scan (Docker Inc., v0.8.0)Server:: Q! D3 K, ^- R( G
Containers: 0 w9 a4 g6 f; V+ p2 E5 R, s
Running: 0: n# y. k- b- Q" ^# C$ |: B8 M: u* k
Paused: 0
" T2 h0 j( y6 |& S! N6 o# M& K* ` Stopped: 0
- {& x. o% V! D- R/ N6 X$ _ Images: 0
) r5 A# M/ t- R4 q" O1 C Server Version: 20.10.7
9 R/ T; X& L1 W* D1 a+ a3 w6 L0 i6 } Storage Driver: overlay2" _/ A' i+ |3 q" r
Backing Filesystem: xfs
' L# F6 S/ R3 V1 @0 x Supports d_type: true; V5 h" H+ f$ U0 N5 O2 J
Native Overlay Diff: true6 x. i3 r4 D+ I# q( L- f# Z0 M
userxattr: false
W0 D2 E6 H c: l Logging Driver: json-file' s7 ^. n1 E9 a. E
Cgroup Driver: cgroupfs' d+ C2 [1 d5 U' b! t
Cgroup Version: 1
2 J7 v' A4 {6 y9 @2 y v Plugins:
2 l9 J( J5 ?8 t; ~7 [& H* C) g9 T Volume: local
- w2 j2 r+ l! e Network: bridge host ipvlan macvlan null overlay* n9 t0 q1 e9 s3 _% a% o
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog5 y( @& B2 t: }# f$ g
Swarm: inactive
! m" Y2 z: }: h8 d6 b Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
; m5 A0 e8 |( m1 Q J4 C2 u8 Q( Q Default Runtime: runc
, V# _4 h5 R! ^' C( y Init Binary: docker-init7 ~" [, u3 C t
containerd version: 7eba5930496d9bbe375fdf71603e610ad737d2b2. C5 B$ z0 C9 N6 @* U, [
runc version: v1.0.0-0-g84113ee0 k( ?; Q1 x; K9 `6 ?5 S
init version: de40ad0+ [& x, _- b8 [& |8 u
Security Options:
2 i# q$ I3 ]: W) D0 F. f seccomp; S- h# `; S8 O6 I; G
Profile: default+ e( s0 l3 Z+ |
Kernel Version: 3.10.0-1160.31.1.el7.x86_64$ h( K$ | c/ t+ f- X
Operating System: CentOS Linux 7 (Core)6 O6 @2 m' X- M
OSType: linux
5 j+ H& L6 y9 y1 I+ U. \* X+ y Architecture: x86_64. Y/ C4 d/ [/ `8 q9 [) A5 j
CPUs: 32
t4 ]0 f8 L( Z( e' z Total Memory: 125.7GiB! H8 L# x( ]4 f$ H( A$ E) U8 d
Name: compute01
3 R. B& R1 O: C2 b4 s# ?3 j8 Y. p, q ID: AFW3:TFZH:XZUS:OH53:CCMW:WWK5:54TT:7QUV:TWQB:D3YZ:34HT:467T
# H7 g6 V7 S7 H9 i3 K' V Docker Root Dir: /var/lib/docker
* X) N9 D6 b/ A$ M! y! i5 p: i Debug Mode: false' C! t5 B @7 {2 ^
HTTP Proxy: http://192.168.2.158:7890/, U7 ~; U) ~) c! q! g) {
HTTPS Proxy: http://192.168.2.158:7890/
' e% Y* h& D# ]8 F( m No Proxy: localhost,127.0.0.1,.example.com! m+ `" h# j9 y, |5 c& E6 g2 [
Registry: https://index.docker.io/v1// V3 r, |5 q( K
Labels:5 Y4 R1 c# K+ ^
Experimental: false4 H4 @: [% {3 j. x; d9 g
Insecure Registries:' b/ f3 q+ \( l. _1 }
127.0.0.0/8
5 i! Y; O9 v9 @. x$ X. j% G Live Restore Enabled: false* ^6 A c. s/ w& J8 B0 x# t/ a: l. t
i2 f6 y1 |3 G
4 P. f& ~4 o; y" f
当不再使用时,我们需要取消这个代理:[root@compute01 ~]# cat /etc/systemd/system/docker.service.d/proxy.conf 8 v4 d O' k! x* c8 Y
#[Service]; H ]* l) h: m$ g& s3 C' Z+ d
#Environment="HTTP_PROXY=http://192.168.2.158:7890/"
! ^/ }! E9 B7 g/ |; y/ H/ X' G#Environment="HTTPS_PROXY=http://192.168.2.158:7890/"
0 D- s- z. \1 i4 r: f" B+ G9 h7 [#Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
1 V4 f# b0 L; V0 \3 s; [0 U4 E$ {3 \' E! V/ ]
重启docker服务:[root@compute01 ~]# systemctl daemon-reload systemctl restart docker.service $ f' [, ?! f# f" y, L' [) c
: ^- e6 R. @7 F7 _" a[root@compute01 ~]# docker info x# B! E E6 m/ ^; Y) _
Client:
3 X5 [" _. F3 F Context: default
& ?, F) _2 ]8 M$ T Debug Mode: false$ y5 p' J7 A: h/ c/ E/ u
Plugins:" E, C' c3 u6 I, w" M* V
app: Docker App (Docker Inc., v0.9.1-beta3)
! O+ n" u6 |4 L* t8 G: D buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
# L) n$ |; r# `+ C, s scan: Docker Scan (Docker Inc., v0.8.0)Server:" U: Y U& A! F* o
Containers: 0
6 W1 g- Y$ f/ V' |- k% C Running: 0
0 ~/ y+ Q1 t( s4 X6 f Paused: 0( N+ b$ _" a0 d
Stopped: 09 U+ Q" C! ?$ l* ~' Q! y7 |5 G
Images: 0- R; J7 l+ X+ F' i
Server Version: 20.10.7
# \ z, \5 g4 Q% ~1 G- n Storage Driver: overlay2
% d0 z# p( G+ e; _/ u4 C6 X Backing Filesystem: xfs& G0 r' E' S' F5 }5 z5 s6 d. H
Supports d_type: true
3 N, y) E H6 P* ]( ~ Native Overlay Diff: true
! e( A, v6 h( z d0 ~/ c |1 H userxattr: false
1 H, c$ Q) U* p7 u' ?, I Logging Driver: json-file
9 n3 L; {% P; L' ]1 w# X- G Cgroup Driver: cgroupfs
% i* |% b9 a( d, {; A Cgroup Version: 1
3 B; A }# n1 q( w) s Plugins:2 V* H8 ?% c& {; [
Volume: local
/ Z8 h' \1 [+ ~ Network: bridge host ipvlan macvlan null overlay, l, _: ]1 ]4 |. B) \9 H
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
% |+ K5 d' e' K0 z$ ^: b Swarm: inactive
* b' Q, Y' B! Z" X: V Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
v5 u4 I6 N) ?3 E Default Runtime: runc
$ v/ x" S7 w1 K, M7 ~8 n4 g Init Binary: docker-init
/ E5 k( n9 G- G: d containerd version: 7eba5930496d9bbe375fdf71603e610ad737d2b20 p0 i4 Y1 K d6 }' s
runc version: v1.0.0-0-g84113ee- t; f/ g& D$ Z' f
init version: de40ad0- v) \1 P! o% N8 x3 {" z
Security Options:
2 A9 I! o! ~) B seccomp& u& t: c( O8 ?0 J( h
Profile: default
+ l& b& a G) o D1 y, L Kernel Version: 3.10.0-1160.31.1.el7.x86_64! e( T$ H4 q) @0 N o) r' z
Operating System: CentOS Linux 7 (Core)
& C# u9 G1 _. Z3 n) d* ` OSType: linux
! o5 B' R5 r/ l; [: b+ |5 ^ Architecture: x86_64* D2 `. F/ l" F1 F2 `* J3 d
CPUs: 32
( d" A8 t! k9 d. U( G* T. ~ Total Memory: 125.7GiB0 s- g0 T5 ?0 ?2 a5 l
Name: compute01
0 E, m" s4 ?6 N9 s$ k, f9 R; ` ID: AFW3:TFZH:XZUS:OH53:CCMW:WWK5:54TT:7QUV:TWQB:D3YZ:34HT:467T
( K; A& A* n# H# g/ H: U+ d { Docker Root Dir: /var/lib/docker
- |& S7 _% U0 R$ ]) c$ { Debug Mode: false3 d7 h. ~: Z: S# A) q: f6 ?8 ?( L
Registry: https://index.docker.io/v1/1 g) B F2 K& [3 l8 P- |- d/ z7 u
Labels:
( |. d5 |) q/ [4 A& `! M# i Experimental: false5 G3 u: [8 a6 m d( U* ~5 \
Insecure Registries:6 v" W" T6 U( M! i
127.0.0.0/8
. r+ g% b1 G1 A2 |; \: b4 @ Live Restore Enabled: false
& M2 A5 G4 g# ] t9 L# i |
|