《网络建设与运维》 podman 服务配置

容器类部署服务

   1. 安装podman服务

[root@linux3 ~]# yum install -y podman
  1. 导入镜像文件

  1. 导入镜像文件到podman容器中
[root@linux3 ~]# podman load -i rockylinux.tar.gz  #rockylinux.tar.gz镜像名称
  1. 启动镜像
[root@linux3 ~]#podman run -itd --name skills -p 8000:80 -v /mnt/cdrom/:/mnt/cdrom -v /etc/yum.repos.d/:/etc/yum.repos.d/ rockylinux:9.1
9a43ec4bfaebfcd0230eb98d07f1a191897c964400806af09408b582b4bc1e48
podman run:启动容器
-itd:在分离模式下运行容器(-d),并分配一个伪终端(-it,尽管在后台模式下这通常没有实际效果)。
--name skills:为容器指定一个名称为 skills。
-p 8000:80:将宿主机的 8000 端口映射到容器的 80 端口。
-v /mnt/cdrom/:/mnt/cdrom:将宿主机的 /mnt/cdrom/ 目录挂载到容器的 /mnt/cdrom 目录。注意两边的路径都是必需的。
-v /etc/yum.repos.d/:/etc/yum.repos.d/:将宿主机的 /etc/yum.repos.d/ 目录挂载到容器的 /etc/yum.repos.d/ 目录。这允许容器使用宿主机上的 YUM 仓库配置。
rockylinux:9.1:指定要运行的镜像和标签。
  1. 查看启动状态
[root@linux3 ~]# podman ps   #podman stop 容器名 关掉容器
CONTAINER ID  IMAGE                             COMMAND     CREATED         STATUS         PORTS                 NAMES
9a43ec4bfaeb  docker.io/library/rockylinux:9.1  /bin/bash   11 minutes ago  Up 11 minutes  0.0.0.0:8000->80/tcp  skills
  1. 进入容器
[root@linux3 ~]# podman exec -it skills bash
[root@a01f36860d55 /]#
  1. 安装服务
[root@a01f36860d55 cdrom]# yum install -y httpd
Last metadata expiration check: 0:02:21 ago on Mon Jun 24 08:07:54 2024.
Dependencies resolved.
================================================================
 Package           Arch    Version             Repository  Size
================================================================
Installing:
 httpd             x86_64  2.4.53-11.el9_2.4   appstream   47 k
Installing dependencies:
 apr               x86_64  1.7.0-11.el9        appstream  123 k
 apr-util          x86_64  1.6.1-20.el9        appstream   94 k
 apr-util-bdb      x86_64  1.6.1-20.el9        appstream   13 k
 httpd-core        x86_64  2.4.53-11.el9_2.4   appstream  1.4 M
 httpd-filesystem  noarch  2.4.53-11.el9_2.4   appstream   14 k
 httpd-tools       x86_64  2.4.53-11.el9_2.4   appstream   82 k
 libbrotli         x86_64  1.0.9-6.el9         baseos     313 k
 mailcap           noarch  2.1.49-5.el9        baseos      32 k
Installing weak dependencies:
 apr-util-openssl  x86_64  1.6.1-20.el9        appstream   15 k
 mod_http2         x86_64  1.15.19-4.el9_2.4   appstream  149 k
 mod_lua           x86_64  2.4.53-11.el9_2.4   appstream   62 k

Transaction Summary
================================================================
Install  12 Packages

Total size: 2.3 M
Installed size: 6.7 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                        1/1 
  Installing       : apr-1.7.0-11.el9.x86_64               1/12 
  Installing       : apr-util-bdb-1.6.1-20.el9.x86_64      2/12 
  Installing       : apr-util-1.6.1-20.el9.x86_64          3/12 
  Installing       : apr-util-openssl-1.6.1-20.el9.x86_    4/12 
  Installing       : httpd-tools-2.4.53-11.el9_2.4.x86_    5/12 
  Running scriptlet: httpd-filesystem-2.4.53-11.el9_2.4    6/12 
  Installing       : httpd-filesystem-2.4.53-11.el9_2.4    6/12 
  Installing       : mailcap-2.1.49-5.el9.noarch           7/12 
  Installing       : httpd-core-2.4.53-11.el9_2.4.x86_6    8/12 
  Installing       : mod_lua-2.4.53-11.el9_2.4.x86_64      9/12 
  Installing       : mod_http2-1.15.19-4.el9_2.4.x86_64   10/12 
  Installing       : libbrotli-1.0.9-6.el9.x86_64         11/12 
  Installing       : httpd-2.4.53-11.el9_2.4.x86_64       12/12 
  Running scriptlet: httpd-2.4.53-11.el9_2.4.x86_64       12/12 
  Verifying        : libbrotli-1.0.9-6.el9.x86_64          1/12 
  Verifying        : mailcap-2.1.49-5.el9.noarch           2/12 
  Verifying        : mod_lua-2.4.53-11.el9_2.4.x86_64      3/12 
  Verifying        : httpd-tools-2.4.53-11.el9_2.4.x86_    4/12 
  Verifying        : httpd-2.4.53-11.el9_2.4.x86_64        5/12 
  Verifying        : httpd-filesystem-2.4.53-11.el9_2.4    6/12 
  Verifying        : apr-util-openssl-1.6.1-20.el9.x86_    7/12 
  Verifying        : apr-util-bdb-1.6.1-20.el9.x86_64      8/12 
  Verifying        : apr-util-1.6.1-20.el9.x86_64          9/12 
  Verifying        : mod_http2-1.15.19-4.el9_2.4.x86_64   10/12 
  Verifying        : apr-1.7.0-11.el9.x86_64              11/12 
  Verifying        : httpd-core-2.4.53-11.el9_2.4.x86_6   12/12 

Installed:
  apr-1.7.0-11.el9.x86_64                                       
  apr-util-1.6.1-20.el9.x86_64                                  
  apr-util-bdb-1.6.1-20.el9.x86_64                              
  apr-util-openssl-1.6.1-20.el9.x86_64                          
  httpd-2.4.53-11.el9_2.4.x86_64                                
  httpd-core-2.4.53-11.el9_2.4.x86_64                           
  httpd-filesystem-2.4.53-11.el9_2.4.noarch                     
  httpd-tools-2.4.53-11.el9_2.4.x86_64                          
  libbrotli-1.0.9-6.el9.x86_64                                  
  mailcap-2.1.49-5.el9.noarch                                   
  mod_http2-1.15.19-4.el9_2.4.x86_64                            
  mod_lua-2.4.53-11.el9_2.4.x86_64                              

Complete!
[root@a01f36860d55 cdrom]# 
  1. 配置网页文件
[root@a01f36860d55 cdrom]# echo "helloPodman" > /var/www/html/index.html
  1. 启动服务
[root@a01f36860d55 cdrom]# httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.88.0.4. Set the 'ServerName' directive globally to suppress this message
  1. 10.测试
[root@a01f36860d55 cdrom]# exit
exit
[root@linux3 cdrom]# curl 10.88.0.4
helloPodman
[root@linux3 cdrom]# curl 127.0.0.1:8000
helloPodman
[root@linux3 cdrom]# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值