找回密码
 注册
查看: 1632|回复: 2

cenos8 stream版本安装podman配置

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2023-2-11 17:30:01 | 显示全部楼层 |阅读模式
1、安装 Podman 和 Podman-Compose。  A( H& B$ e/ Q7 ?/ v

0 O  ~7 u4 f( k6 u0 }& h  }1)安装 Podman:
" x  b2 T) a% Y' B9 b+ S
7 ~( t! K/ j3 I* M[root@host ~]# dnf install podman podman-plugins cockpit cockpit-podman
6 Y9 W- f2 s% y: R) L[root@host ~]# systemctl enable --now podman- C4 ~; W6 I/ ?6 P
[root@host ~]# systemctl enable --now cockpit.socket
* Z* ]' S8 Y+ L安装cockpit和cockpit-podman后,可以通过【https://ip:9090】来管理容器。. {( F, N2 h+ t8 i' p1 d
5 f3 T' M. o- A9 h% n6 |0 D2 M
2)安装 Podman-Compose:
" Z, Q! r2 s+ O* o) r( x9 D  }' E% ^+ v$ J" @. _. n! {
[root@host ~]# dnf install python3
; A8 B, ?( V  U( \2 Y5 u[root@host ~]# pip3 install podman-compose) \6 ]' Y2 B. f& C
程序安装位置:2 ^4 u& U" r4 K9 r; T# Z0 |5 n
镜像管理程序:/usr/bin/podman2 j$ W  N% p( X: x3 I0 @! Q' @
编译文件执行程序:/usr/local/bin/podman-compose
+ d8 f0 S6 H- ^4 W1 t) b配置文件目录:/etc/containers,/usr/share/containers
1 F4 q! u2 {. D/ \+ x0 F9 n( s- B  f0 o9 z
更新- v: u% ]& ]. v6 w" o! h9 C; q
! w. G9 E+ z, m6 Q; U1 s) v1 P
[root@host ~]# dnf upgrade podman
  b2 U1 ^# N& Q& w( u[root@host ~]# pip3 install -U podman-compose
5 ~- H" X& m$ r7 t$ r- |7 v: G6 p$ _9 _1 d1 m( o3 j4 e9 i
2、设置国内镜像仓库加速器。
- e0 Y3 m- @" s  D! _6 l2 O) P0 I) d5 c' T& a6 O" s
1)备份原配置文件:- D2 Y2 |, C- X! ~; z4 n6 s/ W
& N  t0 J0 _/ k( r) u: `+ z1 K8 E. ?
[root@host ~]# cp /etc/containers/registries.conf{,.bak}
7 b  X; h, G- Q% v: z9 E& g2)使用文本编辑器打开配置文件:
( h( [- q2 f% h5 ]7 W! r% L
9 E+ D0 f# i( g  I( V: [( K[root@host ~]# vim /etc/containers/registries.conf5 s# Y4 n( n: E. a9 s* [  N4 x9 h
3)删除原有内容,重新编写文件内容后保存:# U0 B/ E) s. N( [" l

* T8 m4 I( l. l+ Tunqualified-search-registries = ["docker.io"]
8 E0 F# t8 G: R2 `( F. F
4 z9 C& v: ^# ~7 }# y- N[[registry]]
$ D  @8 y2 @, w8 v% O; Xprefix = "docker.io"! v4 m! x. z# P
location = "docker.io"& s. p- W' b3 v( Z& d9 T
8 x" C- j, \/ ^% C1 G/ y! d! e; |
[[registry.mirror]]
5 a: T9 t9 t* blocation = "mirrors.tuna.tsinghua.edu.cn"
- Z& l% o* _7 k. L2 U
4 |3 X6 G, ~( `- C5 v' e# c) f. w  Q2 I$ N5 f  _
4、设置镜像仓库和运行时目录。
3 a+ ?/ k( c5 K; r2 H& L
; R4 z5 c1 J; b# K! u% C: J1)创建镜像仓库目录:# D& c1 v( V5 ~0 W) T  S" a0 V1 G
2 i4 C9 h) ~7 N& M4 j. R" [3 s
[root@host ~]# mkdir -p /data/containers/{run,graph}
5 V# \# Y1 m* P' L2)备份原配置文件:
- Q" [; U; ]5 z& E4 b
/ `) [, s3 [" P/ D9 }4 Q[root@host ~]# cp /etc/containers/storage.conf{,.bak}  A8 a& H9 R+ D
3)使用文本编辑器打开配置文件:$ i- L2 m, |" J8 u+ p

. |. K7 Z3 r' ?$ m2 @[root@host ~]# vim /etc/containers/storage.conf
2 s. b* u) H& I' K. I2 \4)修改文件以下内容后保存:
$ L- B0 v5 {8 V0 A8 e; i- J4 x+ S/ m6 M) W' [
# root 用户运行时目录- d# K3 w- @( |/ Z5 X  a' R
runroot = "/data/containers/run"  N6 l0 B6 g0 n* d; B& N5 C! J! ]$ d7 _
+ q) k& L. W$ F, H
# root 用户镜像仓库目录
% O8 p; e3 W6 ?; W  M/ w( ], r1 l. Cgraphroot = "/data/containers/graph"
6 \! D! p9 ]0 F) [6 }( ]4 }8 y- b9 u1 p# Y  Q
5、修改 SELinux 配置文件,永久关闭 SELinux。
' U5 C% z# ^9 a1 u% v
9 O4 t5 F6 N9 d, Y. m. e使用文本编辑器打开"/etc/selinux/config"文件:
2 H/ ?  D( W# j- x3 E  g
$ N. m: O- C9 @" G1 Q4 F) O% k[root@host ~]# vim /etc/selinux/config9 O6 _; p* ]8 P; a% x* [9 `
将 "SELINUX" 参数设置为:"permissive" 或者 "disabled",并保存:; o/ H0 ?  ^+ C

! ]& E4 ^' q( K7 I! P* O1 o  Y( j* O$ }) r' R9 b3 @# P
#     enforcing - 表示启用 SELinux 安全策略。" y$ e/ o6 A2 M. q# f
#     permissive - 表示启用 SELinux 安全策略,但不强制验证。如果执行第一步可以正常运行,则建议设置此值。
, w9 q( N$ L1 }#     disabled - 关闭 SELinux 安全策略,相当于没有安装 SELinux。
% u( N. [6 z3 L. tSELINUX=disabled
% N# V/ S" n' u8 Q0 I" y, g6 `5 M, t9 |5 Q/ R6 z
8 a0 d3 G8 ~% i- t& g
重启服务器:
" k# E5 q1 B) j# k+ g* J# t7 e/ Z& C" S- c
[root@host ~]# shutdown -r now$ D% P2 x  Z4 z! s: d

+ J* v. q0 v7 H, N: Z; o  z# t5 a

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 17:30:02 | 显示全部楼层
podman的配置文件 /etc/containers/registries.conf! h  X5 ?. {: w4 e1 ]. H: s; H$ w2 D
全局配置文件: /etc/containers/registries.conf
# Y' s% F4 G. h$ \0 \用户配置文件: ~/.config/containers/registries.conf. U$ _6 ]+ U& R1 c4 s$ H
备份原文件
: k/ T! D9 u0 {+ U. X9 U: T2 n/ O1 h5 W# }
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.bak
9 N. i; l* l# k8 y6 ?4 T1 n. ~. ^7 c* g+ Z, h) Q' w
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.`date "+%Y-%m-%dT%H:%M:%S"`.bak" q( n, [0 h6 i6 h+ ^+ M

0 `1 Q5 ?* v  b7 Xsudo cp /etc/containers/registries.conf /etc/containers/registries.conf.`date "+%Y%m%d%H%M%S"`.bak, J2 K. u6 ]3 N0 Z, g

2 a1 C' F+ o& Q% Rsudo cp /etc/containers/registries.conf /etc/containers/registries.conf.`date "+%y%m%d%H%M%S"`.bak
9 Z: N/ S! p0 e3 O
2 ?" H4 s1 |# W: s' T* m+ W2 {3 P[ -e /etc/containers/registries.conf.BackupDir ] || mkdir /etc/containers/registries.conf.BackupDir
) ]* I, k$ E/ F. I$ \sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.BackupDir/registries.conf.`date "+%Y%m%d%H%M%S"`.bak3 i2 c3 e: P+ W4 @

9 ?0 |) e; }, h& e9 Q/ F: \! w, R编辑. v% p3 g' O' y5 |- I" r& W
: x/ s: j/ T4 R9 Q
sudo vi /etc/containers/registries.conf
+ i; u# K7 Z- I  h4 @* }5 b: H+ P7 `! f
+ c9 b6 _& [( C( M3 u0 v6 ~& _sudo vi ~/.config/containers/registries.conf
: H1 @7 ?; n. W( i( V+ p5 U% n9 ^% O/ B
查看
# ^) S0 o- b" b2 H6 F$ n6 J: O) S* h9 M' P# n  O
sudo cat /etc/containers/registries.conf; R- ^; X2 l1 E
) t1 Z0 {1 V& d: w
sudo cat ~/.config/containers/registries.conf
* `, b# x% j: }- B1 h% z
! e; d) g6 u' csudo more /etc/containers/registries.conf9 J. G6 h" L& @) b9 v8 y! b

+ R! G8 |  V. M9 Z% [* ?sudo less /etc/containers/registries.conf! b) A3 G3 [6 m$ ~  s9 ~9 ~+ H2 U
5 o; C& N1 r7 Q1 d1 f
其中prefix是pull的时候指定的镜像前缀,location是获取镜像的地址,如果不指定prefix则默认和location一致。insecure=true表示允许通过HTTP协议来获取镜像,对于私有化部署/内网测试环境下无https证书的环境来说很有帮助。6 x" f/ t7 q8 j
+ Z; @, p- h/ q; D$ X' |
配置单个镜像源
% @; K' M+ ~& r0 W; d
0 _  Z* X! E6 T" t# G! r' i9 D使用中科大源
  g& o' m# L) S' m5 ]9 F3 g; J. {
###  CentOS9原版 unqualified-search-registries
* e8 h+ F' u( B' w4 b4 \" v# unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "registry.centos.org", "quay.io", "docker.io"]
6 ^7 s& E" v- ?* o* S$ x
+ d' B" x! E9 `4 R& d2 x& r7 [###  Fedora36原版 unqualified-search-registries0 @4 V# B9 r5 h5 n
# unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "docker.io", "quay.io"]( J- u, V3 \( G6 x

  s& X" R- y" F###  Rocky9原版 unqualified-search-registries
% s+ i, E+ M/ e2 }2 Z. s. F# unqualified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "registry.centos.org", "quay.io", "docker.io"]
6 p  ?1 v+ i* S' X" s9 M' @4 V
###  AlmaLinux9原版 unqualified-search-registries
( C# K. P2 ?& u6 _  A6 ]* ^- [# unqualified-search-registries = ["registry.access.redhat.com", "registry.redhat.io", "docker.io"]- @" N% W5 ]$ n- _+ y, P* b
, ^6 L# ]" c$ h* j8 l! E3 n" a
### 取消从默认地址搜索的仓库域名
" V$ |' v: ~. u( M4 q& @; dunqualified-search-registries = ["docker.io"]
; ?' H( O. q1 `6 z; z: c- _" i; i
! M! |# @4 u! e  B/ \2 j### 自定义搜索器
* J  \8 }6 S4 L4 S  w[[registry]]! b8 R1 |7 k  }  ]
### 仓库前缀; t1 W' G. }& j" ^& K' V7 W% t
prefix = "docker.io"
8 z* W( ]" G, n, s  R; t### 加速器地址
3 d/ d, q2 N$ I( p  k7 ^5 m8 x! j9 Llocation = "docker.mirrors.ustc.edu.cn"# J% g4 p) N4 B) O5 q4 m6 c
### 允许通过http协议获取镜像8 l, M4 _" A8 b* i" ^
insecure = true
1 m2 @* z; s* x' O- d# }
8 }7 V. c, y1 l# p& d7 x2 F
* k# p4 a: K, \$ Q2 t; H( b* E, Q  L

: M$ C) \* I1 _0 d6 ?( E. n) o使用docker中国区的源* D" N' v! n; A! v7 L  H

$ ?) C: N; |2 K6 d. n( @unqualified-search-registries = ["docker.io"]/ U# i  \8 \, x- \) s! k
- s0 v* j. N. a
[[registry]]# m! F# j, `. \7 p, o, p
prefix = "docker.io"4 O5 W" {3 V% k6 ~' w, ~4 n/ @7 I
location = "registry.docker-cn.com"
7 @0 W$ U$ s7 b. F$ ainsecure = true/ }! ^/ Y5 g9 d$ p+ G6 d

( H- R9 Z; m! g4 J+ j
( l3 v; u+ P8 X2 Y8 M. z使用163源
% H$ |2 ~3 H1 Z3 v) ^: @9 l9 D7 x/ Q1 g! s0 ?' r; F* L* \
unqualified-search-registries = ["docker.io"]
8 E; i% R: K+ q; {# q
9 M2 {4 h; r& U) M8 C$ Q[[registry]]
7 E3 o3 X4 |3 Kprefix = "docker.io"
2 K: T8 D/ {" T  T1 Elocation = "hub-mirror.c.163.com"7 `. n) d- V8 b
insecure = true
& S. [& }- w6 k1 D7 x- {7 Z; Q: S9 V& v2 I, Z( |4 d
# P2 c. H, R9 k1 F& x* b
使用阿里源/ f) D: [( F' K
; I( _6 l% [; T- g
unqualified-search-registries = ["docker.io"]) ]0 t: m5 t4 j( `5 z% A+ E, S
$ h8 z5 ~) V& Z* F# w% q" K% E
[[registry]]# n! @6 m' G& P
prefix = "docker.io"
! D8 D$ L0 R1 c9 u/ s) ilocation = "xxxxxx.mirror.aliyuncs.com"
  L- m! v% n" P( ~. k# Z. R' v8 S. v3 M$ j# V6 Z8 I
: j* w, G+ @  ]4 V4 k
3 ^. r" k8 f0 |/ i& `  Q) E. Q$ w  I
配置多个镜像源0 b3 t1 {6 y# r- _0 O8 D6 M

) R9 @8 @- m$ t% y4 a! N' punqualified-search-registries = ["docker.io"]/ T2 u* @, b4 h, J5 X
# Q! q( `3 o. |2 [5 \' m+ v7 x9 T. H
[[registry]]  ~; u6 j/ ~; [5 w5 V
prefix = "docker.io"
  d1 b7 |4 m8 w% }8 N! Flocation = "hub-mirror.c.163.com"* A; D$ B8 a4 ^
insecure = true
: S" B' q; x4 b0 d  a/ x  A4 T
7 O2 }  m2 F, {[[registry.mirror]]# r0 g2 z0 ^8 Y, g. ]
location = "docker.mirrors.ustc.edu.cn"
  N; F: Y$ L; M" k9 O5 Binsecure = true
- t' r5 N; U' g7 Z[[registry.mirror]]
, j* X8 a0 f2 d2 |" Ilocation = "hub-mirror.c.163.com"
' y% [* @0 T( K& s; einsecure = true
/ l' M" z! ^# c& O' `1 u2 O6 ][[registry.mirror]]$ `4 @- J, c# q' R
location = "registry.docker-cn.com"
% m( C& t* T' i8 minsecure = true
8 j; ?. e  p+ T' ^" J
  e& V! a4 U5 a  l用脚本配置
% F1 N) @% n" ^- D$ B* ^6 q
* U4 ?; W9 d3 L& a# z/ B- g1 U4 ^#!/bin/bash
" Q4 }" b; {3 n[ -e /etc/containers/registries.conf.BackupDir ] || mkdir /etc/containers/registries.conf.BackupDir, t2 }3 y4 Q3 D0 i/ _( x
sudo cp /etc/containers/registries.conf /etc/containers/registries.conf.BackupDir/registries.conf.`date "+%Y%m%d%H%M%S"`.bak
6 n) }7 g2 v- O! uprintf '( ]2 A  @  C& f) j! T& z' u; A1 c
unqualified-search-registries = ["docker.io"]
1 n% F# q6 @: T' C: Z; }) n. w# @8 d. [1 U
[[registry]]
. ]6 T$ T2 {2 `" ~prefix = "docker.io"
. w7 {# A( l5 k7 d4 H9 o5 L3 N) slocation = "hub-mirror.c.163.com"
4 P4 Y" j9 \/ g  b* @" a" tinsecure = true3 o7 j& v$ j: y( w6 ]6 q
[[registry.mirror]]
) e& V: X% E! ^3 a$ |, Jlocation = "docker.mirrors.ustc.edu.cn"
" D3 X9 p0 Q1 w9 a. Minsecure = true
5 o, w1 |# X, j" Q! N* L0 b[[registry.mirror]]
; n/ K+ G  S* K' w5 [% L2 B" Klocation = "hub-mirror.c.163.com"% [# K  ?6 U& E, a+ e  s, S
insecure = true
, o+ t2 z$ n1 }/ |+ [( w[[registry.mirror]]3 }4 w; L* d6 Q% ^$ Q
location = "registry.docker-cn.com". N9 l9 ^. K5 u* E: o& d% h
insecure = true. o2 Q# C& a2 N$ i) O* B7 @4 q, J  c& ^2 B
' | sudo tee /etc/containers/registries.conf' d* J" Z0 z7 y4 C1 D
0 `8 v+ J+ z/ b1 y: h* a
6 v, m3 G8 ]* r; E: k3 ~4 p
测试,查看信息# p" Q  v* A' X- }5 ]
# H8 p4 O4 p( X3 O
sudo podman run hello-world# F" m4 {% D  t3 j: i

: c! D/ w6 y8 w# K1 q, Y+ _sudo podman info
; m, {1 D8 Z  n! K
. B& y* T/ |4 \9 z# Z; S9 C8 I% {" f+ ]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2023-2-11 21:49:24 | 显示全部楼层
安装podman:) \( E4 J$ T9 w# _
dnf install -y @container-tools' i/ l! f9 ~8 J: d' n
dnf install -y podman/ p6 Z2 M- k5 f
安装podman:) S9 k1 H7 c/ K" G! a3 {7 w! v- g
dnf install -y @container-tools
& ]% F8 `+ F5 ~1 t) k# h, ^dnf install -y podman
, o3 c7 |: k. e
1 X* G+ a$ H) z+ \, D备份文件:
3 @9 _  c  F) y* w8 j6 ]cp /etc/containers/registries.conf{,.bak}2 }7 W7 a0 e5 f( \; V- v  j! @
% K& t' E( ]. K! ^! Q# K
修改文件:1 @0 ?1 ~5 P" C# C, q+ z4 R- G; U8 J
vim /etc/containers/registries.conf
# c+ H1 J: o  Z+ n去掉红帽的哪些配置,只保留下面的配置:
' k. i. ]: [8 Runqualified-search-registries = ["docker.io"]0 `+ }) Y7 ~, [; T7 B1 a& Z% c
unqualified-search-registries = ["docker.io"]
- m+ [" K2 L) d6 E; {- a2 U[[registry]]
/ n+ [( O& o+ A$ yprefix = "docker.io"
: {3 f6 R! Q- J1 E* ?" R5 xlocation = "docker.io"4 g0 K* }4 k/ ^% j* W0 h+ X7 E6 b
: Y  M" D5 k+ w. j
[[registry.mirror]]$ }. |* y" \- ^" t
location = "mirror.baidubce.com"
$ `' u7 ]- y, a- D8 t4 D5 v2 T/ x2 g1 x. h
dnf install -y podman
dnf install -y podman podman-plugins cockpit cockpit-podman
systemctl enable --now podman.service
systemctl enable --now cockpit.socket

3 ]: c: {. D# Q* D/ F* ]4 x; N* [- v( P- N' Q% n
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-12 03:24 , Processed in 0.017784 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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