|
|
楼主 |
发表于 2023-2-11 17:30:02
|
显示全部楼层
podman的配置文件 /etc/containers/registries.conf
, W; Z& L! X' z) I2 F全局配置文件: /etc/containers/registries.conf
. I5 V& P" ^6 m; g2 ?' P用户配置文件: ~/.config/containers/registries.conf
- z! N$ P- A7 u `( D备份原文件" c0 P- g5 A' c
& u1 _( o5 ~- Q( ]' d: k
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.bak' A3 F' H4 b1 I( x {
1 j; D# @5 ^. F+ F9 k7 y, D
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.`date "+%Y-%m-%dT%H:%M:%S"`.bak
; p4 C3 `, D X* C$ y. ]/ k6 `% O- |
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.`date "+%Y%m%d%H%M%S"`.bak
2 d. p* i; |- c$ _# N0 I/ | O1 q$ b$ x. V& w9 o6 r" X' P1 f2 _
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.`date "+%y%m%d%H%M%S"`.bak
$ H& o/ z4 {# _0 d7 f( [7 T$ m9 Q, o* F9 g, i
[ -e /etc/containers/registries.conf.BackupDir ] || mkdir /etc/containers/registries.conf.BackupDir
! k2 [+ ^0 _! i3 J5 g% P4 gsudo cp /etc/containers/registries.conf /etc/containers/registries.conf.BackupDir/registries.conf.`date "+%Y%m%d%H%M%S"`.bak# F& s. D; }. U% }- {9 N
~" K7 d7 Q/ h: R编辑
h' O P/ U2 D$ W0 V) w3 @( G0 Z% _8 W% e8 K
sudo vi /etc/containers/registries.conf
% L) b7 ?4 w1 q+ p! ^" D7 [4 g0 ~! ~* h8 X7 n( O7 A
sudo vi ~/.config/containers/registries.conf
1 c, E0 Q& U& q0 h
5 x9 j" c; K7 T9 A/ w查看
+ |8 L6 W9 b! O' b9 f1 r3 Y! F8 [* t
! C$ a, P" r' x2 _# e3 Psudo cat /etc/containers/registries.conf
" v/ y. [; @% q7 p* r$ i+ \9 j
+ V# Q" k5 R! I9 n. I! Lsudo cat ~/.config/containers/registries.conf" o. ~/ p, Y* ?/ _ O
& U5 ?2 u1 d+ A9 _* E4 F- S' H
sudo more /etc/containers/registries.conf
9 {. g# ~$ l0 _+ |0 ^
4 D% w" h2 o, O O# z' Ssudo less /etc/containers/registries.conf& s3 c$ S5 L1 T4 Z3 M; G( i
. X% W2 w: L' E7 L- n! {( Q$ x其中prefix是pull的时候指定的镜像前缀,location是获取镜像的地址,如果不指定prefix则默认和location一致。insecure=true表示允许通过HTTP协议来获取镜像,对于私有化部署/内网测试环境下无https证书的环境来说很有帮助。' D2 a$ M3 S" k. E
& N0 e# J" f6 J& p配置单个镜像源
5 [- a5 L8 k8 O$ h* I% v5 V2 m7 n' J! d- [' J/ J) A
使用中科大源
) c% A b* P& h% ?0 }# H' ?$ f8 h
### CentOS9原版 unqualified-search-registries3 x4 ~+ {+ T5 F/ c8 h: P
# unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "registry.centos.org", "quay.io", "docker.io"]
2 \8 ^3 |8 r" b9 p& u' k9 R! J1 D* u7 Q& a! }5 q
### Fedora36原版 unqualified-search-registries
" e1 z5 t0 B3 j5 ?2 ~# unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "docker.io", "quay.io"]& z, g1 v1 e3 D8 M& ~% w
6 V( [6 y. C" g$ K9 s" D% X: F### Rocky9原版 unqualified-search-registries0 E% l1 U* X1 W, ^+ Z( q
# unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "registry.centos.org", "quay.io", "docker.io"]! f4 V4 o% ]( D( j x9 X0 M" ?
1 s; I7 z3 ^& O4 C
### AlmaLinux9原版 unqualified-search-registries
) X4 u7 ^" w8 A/ `# e# unqualified-search-registries = ["registry.access.redhat.com", "registry.redhat.io", "docker.io"]7 s: _' V6 w$ C: ~, A$ J; L
0 L) I3 X) ?: H4 t" Q
### 取消从默认地址搜索的仓库域名
; f4 V& d1 H+ M0 ^/ W$ j: } {+ s& Bunqualified-search-registries = ["docker.io"]$ W+ M7 A' ?0 M+ N% x: a
5 c Z% d7 V0 c. u
### 自定义搜索器" [5 Y! L# ?4 h
[[registry]]
; n# X, y& h2 G7 G### 仓库前缀
/ R# E/ W, f3 Y4 Hprefix = "docker.io"- B. N" @( P9 X, ?. p4 h; l( K/ T
### 加速器地址6 l! r+ I0 g0 J
location = "docker.mirrors.ustc.edu.cn"
8 E& j" F9 F$ Y+ U) v8 u### 允许通过http协议获取镜像
2 S1 s* P' E' g6 S+ Q# ~6 Oinsecure = true
0 F, @. d w- C( }% x" q! G8 N' Y
9 I: ^8 ~& v1 \9 M* N- B
3 G: D" v7 A( ]5 O9 |1 ?5 _
# M8 A O. u9 Z" k8 T3 B9 m使用docker中国区的源% \5 V/ o6 K8 [( h. S) m
# Q0 P) F$ ]" h, v) R
unqualified-search-registries = ["docker.io"], c7 V# P3 b6 I( i. q- _
- P. u" k5 ^" U a7 Y6 d
[[registry]]- z' L! d- b- B$ o: W
prefix = "docker.io"
( f+ c8 L9 Y' Z' w* I5 e/ Wlocation = "registry.docker-cn.com") Z5 j2 T& [' Q* i7 ?
insecure = true
1 g# a+ @7 G" y4 e# C% W" v7 J
% |# a/ a% Z' f4 b
* k2 G, h2 I$ B M( ]使用163源" {' T+ k4 ~, j
5 M, z9 Y& Y( e+ b2 [2 i+ W
unqualified-search-registries = ["docker.io"], I* P) T9 ^6 X$ C& u
# G8 K: [0 B% o" D/ k[[registry]]
- m4 A/ P7 _+ H5 d7 @( d9 [4 |: [prefix = "docker.io"
" h, C R3 B& d: b/ |location = "hub-mirror.c.163.com"
- U. _$ D5 M- Q. ]7 Dinsecure = true. }. j; \! t! u: V) `- c- ?8 a
! |+ T% t6 j( d8 B0 U7 q, y( x6 n
# I' l1 q# ]5 ~( s- G+ t: O( f使用阿里源" P. w; e. w/ U+ ~! o( m6 t
0 M# X+ q3 z" l& o f! `) z, Sunqualified-search-registries = ["docker.io"]+ f1 G4 b9 n" z% n8 q
6 }2 Q0 P _# G3 P0 t. T, p[[registry]]
! B N1 |3 \9 {prefix = "docker.io", O3 k* G$ m" K( Q" n0 }" A
location = "xxxxxx.mirror.aliyuncs.com"
6 s8 H' b$ m+ s" b
# \0 T$ b+ m$ F8 Z% K5 `7 t4 L$ y: C' S+ \
8 D' G& z! I; |8 B3 s* W: G
配置多个镜像源& ?7 T w( i" G" V& G
8 |. d, |" j7 N0 t6 j
unqualified-search-registries = ["docker.io"]9 W2 `' H+ [3 A7 E
9 B9 w. y4 K3 h* S( e- u2 S" b
[[registry]]
1 n6 m" R" F e/ T; P: Kprefix = "docker.io"3 D: g# T+ |+ w6 f( c
location = "hub-mirror.c.163.com"
6 v; G* U4 _. e( winsecure = true* u% @3 e w0 R5 \1 E
9 W2 b$ _# _! B8 f& o2 k, R2 i: x[[registry.mirror]]3 f: V7 `$ [& E8 S
location = "docker.mirrors.ustc.edu.cn"7 k1 m( O9 l$ V8 S7 e& b( G" Q
insecure = true
1 P S, A, F3 u6 r o& U! z4 h[[registry.mirror]]
0 N. p* v }$ nlocation = "hub-mirror.c.163.com"
3 Y- r0 L* `/ ]4 K# x; winsecure = true
5 K, _- x7 [) r5 S( U! B[[registry.mirror]]6 D: Z; N+ g* k
location = "registry.docker-cn.com"
1 S7 Y8 t, v3 A) z: Finsecure = true
. S6 b2 i- F2 A- w/ q- Y7 e$ A% ~* [# M
用脚本配置1 k8 |( d% o. ^" O1 n2 t2 B( D
# v) n5 Q8 C0 m+ |, C#!/bin/bash/ P: V$ Q' q v. C1 J* Q( o
[ -e /etc/containers/registries.conf.BackupDir ] || mkdir /etc/containers/registries.conf.BackupDir# p6 N8 Z2 }6 p
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.BackupDir/registries.conf.`date "+%Y%m%d%H%M%S"`.bak
2 h% u$ `% O& V; x7 c7 c, d( jprintf '
0 J+ F$ B4 g6 |! H. ~8 a# uunqualified-search-registries = ["docker.io"]
. t. U1 f. J( A( s ?; z' B7 A; v
[[registry]]% E. ~8 ]; f9 ]
prefix = "docker.io"/ `" D: l) v E
location = "hub-mirror.c.163.com"
8 F+ A- S3 [: d7 T J3 oinsecure = true
5 k, N$ J2 I6 j6 U9 y% l[[registry.mirror]]
$ E2 y" v4 O; l/ Dlocation = "docker.mirrors.ustc.edu.cn"
3 b2 N% {( \- U. \insecure = true
5 v+ s2 n: G2 K2 \0 t[[registry.mirror]]
# C1 B9 i/ s* c: p# b! glocation = "hub-mirror.c.163.com"
: E6 k, B6 w! Tinsecure = true3 t7 v' h: `, Q/ ^
[[registry.mirror]]3 R# C7 k! }$ k4 V; o! s# k9 ?9 G% T
location = "registry.docker-cn.com"8 Z8 H' ]9 L+ q- Q/ |$ G! [( g
insecure = true
4 b6 Z/ G) M1 S/ w5 r, f4 ~' | sudo tee /etc/containers/registries.conf/ M) Q! ^. K, x$ Z0 I! C3 @' Q7 f
) d j0 @# f4 r4 E: J# t8 }; y
% R8 a1 V- ^" S# C9 N% `测试,查看信息
% U0 a' Y0 `. r8 P9 y
6 ?8 q9 e/ w: M$ |, y3 V* x0 J/ jsudo podman run hello-world
- J' Z; y: G: E: r! ?3 k3 Y
2 Z3 ?* C! S( G+ hsudo podman info
: C2 q. i, j4 ^4 q; Y2 d
U) A; c7 [$ B5 N6 m( X R3 R$ F! I: K3 L5 ? H m/ J9 I
|
|