|
|
[root@c63d7538a2ca /]# yum install -y net-tools
; @8 `0 U: I) t" _+ }$ R0 i& B4 ULoaded plugins: fastestmirror, ovl
" c7 f _6 m% @6 F' z) ]Loading mirror speeds from cached hostfile" V9 U& E# F6 L' C# I
* base: mirrors.huaweicloud.com$ C( b' c0 p) M7 N( a! U- k" Q
* extras: mirrors.huaweicloud.com# c! ~ ^5 [* C. p# A: O
* updates: mirrors.huaweicloud.com
- N4 v) I# C' Y, O& JResolving Dependencies
, @5 |& i" I* Y" z) p--> Running transaction check
9 b) s5 K! j# m8 Z; ^5 n---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
4 {# [. J$ n# ?1 O# |2 Z6 c--> Finished Dependency Resolution
# H! Y- `9 b( H7 G; \
0 c4 F/ L# M! K6 wDependencies Resolved
: |8 v. R4 S$ G7 F, _# x( R2 y' j* S
================================================================================
- `# I3 d' |$ X- D: h7 l Package Arch Version Repository Size
* A; t' d: I1 z" Z1 ~================================================================================9 l/ p. ^/ ]7 h- ]8 \2 J
Installing:: s0 b$ x& _- U6 V: l) ^
net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k( m% C* H# ]4 H4 V
; H6 e) E9 E) u
Transaction Summary
: s) I# ~4 B# Q- C================================================================================
6 m; Z( T/ W J; |Install 1 Package
; ?$ F6 R" \2 o" T+ N$ b2 {) U3 O$ j8 j3 `* ?. }
Total download size: 305 k: l/ q2 K" \, J- z7 r) [% V( d+ h
Installed size: 917 k( i) u7 ~4 I7 p2 R8 {! @
Downloading packages: P7 V- R" p7 S7 y+ v* Z0 ^) t
net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kB 00:02 - }5 }- C T+ E
Running transaction check
! B6 M; f( L6 q. Z# _0 B- C NRunning transaction test
) f' J3 Y6 Q+ A# B5 OTransaction test succeeded6 l* s# W9 d; O) }- {. I
Running transaction
# u+ E3 m+ [, { Installing : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1 * m. R: Z2 V" L& e. a0 [
Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
7 ?5 Q* }9 O' J8 q4 V4 T1 b
2 l; P1 q* {# v9 l! qInstalled:9 ? O8 y8 x+ U/ _9 q
net-tools.x86_64 0:2.0-0.22.20131004git.el7
. ?4 J* C+ f" b$ S! [0 |+ I: ^' x1 h' ?/ L' }/ {+ j1 j
9 I) m+ t5 c3 f$ N( F/ W- c
[root@c63d7538a2ca /]# yum install -y vim + ^' b( [& V: E4 k6 v& g/ L
Loaded plugins: fastestmirror, ovl, O4 D4 t4 P, L# ?4 }) }5 ?
Loading mirror speeds from cached hostfile2 W# c$ M# V7 |/ b5 P7 J( q- Y
* base: mirrors.huaweicloud.com
) c# O) s/ ^+ b8 r) a' Y, S * extras: mirrors.huaweicloud.com
+ W) Z$ `( C* S" m; \ * updates: mirrors.huaweicloud.com
3 r& \/ |8 ?2 |* y U- p: qResolving Dependencies' e- j( A( i9 q# m$ A: e3 w
--> Running transaction check8 h" A' g( d4 z6 X% F
---> Package vim-enhanced.x86_64 2:7.4.160-4.el7 will be installed
& t; L' I0 V$ \: ?6 w4 ^/ d/ n! F! j: X$ p- {& w
安装的包,可以使用它,制作成一个镜像# @( q( k0 |$ P) R+ ^1 ]+ K0 `; \
步骤如下:; S. `1 r. E0 n" C) N
[root@dockerserver ~]# docker ps
3 \- _' K% ~: r: C: e* fCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES( O5 A3 ]: t% Y* U9 C
c63d7538a2ca centos "/usr/sbin/init" 24 minutes ago Up 23 minutes hungry_bose9 ^4 [8 N6 |5 K+ u, K
hungry_bose是docker 为我们的容器随机分配的名字:
% a* X. [/ y9 t* K Z0 r执行 docker commit 命令将容器保存为镜像
' L8 e1 S& h+ J5 ]% A% k- O
; a, d% R8 @4 D& q5 T4 v0 i[root@dockerserver ~]# docker commit hungry_bose hungry_bose_vim
+ c, W/ f7 ?8 y: ^# P4 a# `sha256:7119d12ac7bff5dbec177f268843c83209379f90fc33bff6bc2e06b3cfe2a4539 j+ L: ~& V; ~4 ^. \# y
$ {9 {/ g6 _* M[root@dockerserver ~]# docker images4 _" O; A0 s5 S! I' [
REPOSITORY TAG IMAGE ID CREATED SIZE7 Z' s+ X& G* t' Q# h$ _$ D1 ` e
hungry_bose_vim latest 7119d12ac7bf 35 seconds ago 368MB( e$ G% U$ g3 `1 w! ]' V7 R
centos latest 49f7960eb7e4 2 weeks ago 200MB! }. Z( r4 {2 s5 v! \
* K6 P( [0 ^! x4 ~2 a# q从size上可以看出镜像变大了,因为安装了软件而发生变化9 S$ {8 v) Q. L+ s
从新的镜像启动容器,验证vim已经可以使用了。6 \" s1 j/ f: ?4 c
[root@dockerserver ~]# docker run --privileged -it hungry_bose_vim /usr/sbin/init &
: ^6 h1 ?' k4 C/ j* C3 Y7 `7 k[3] 7826 {" L' {+ j5 P7 S; p0 M3 n
X$ v8 P4 |: d) Q0 k
, k$ ? T* L# R4 O, `# }
: I0 y8 Z* ]' F* d, Z6 _( a7 C1 a. W
[root@compute01 ~]# podman commit stream8 centos8:stream8-1) G6 h8 l, l1 z; v) M' M
Getting image source signatures5 r2 j' f2 e. V: s: q
Copying blob c3dee2a613b9 skipped: already exists # \4 x7 `- v0 I$ n: }! ^" |
Copying blob f53b51bcab65 done
4 R: e" M ^8 U: `! t5 ^+ Y( vCopying config f3e7aa6982 done / B/ H; Z* b$ }* |* ~0 s
Writing manifest to image destination) M* |- z: V( \/ b
Storing signatures
+ v6 S1 m2 I( N7 j; j# N0 y1 Df3e7aa69823b8a3557c704d836a91f3a02628059a26246310e283e2b65ff97bf% {5 L2 n: h( F. a
[root@compute01 ~]# podman images
9 d" s3 o1 T4 f! V5 f% h5 qREPOSITORY TAG IMAGE ID CREATED SIZE% v. b2 S- E% e+ C, p) G
localhost/centos8 stream8-1 f3e7aa69823b 21 seconds ago 1.65 GB, h4 V( l2 r- b$ _' _6 Y: l
localhost/centos8 stream 6fd6181ebba0 5 hours ago 1.65 GB
( p8 U% `' j" [: d
! W. p3 R+ x$ ?; ^+ {& [0 Y8 _- Y[root@compute01 ~]#
) D" G# j9 S. O4 o启动容器:
% G8 [- O' l+ ?7 j( @7 m& ^* O( K[root@compute01 ~]# podman run -d -t -i --network=host --name stream8 --restart=always --privileged=true centos8:stream8-1 /sbin/init /bin/bash
! B! G1 T K/ ]/ z( }7 h
; k9 D4 W5 Q0 ^$ N8 N |
|