podman实战学习

实操练习:almaLinux系统上podman容器安装centos

1.almaLinux系统安装

见:安装AlmaLinux9-X64_醉里看星辰的博客-优快云博客

2.almaLinux使用podman容器安装centos7.9

2.1下载镜像,启动容器,登入容器

[root@192 ~]# podman pull centos:centos7.9.2009
Resolved "centos" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/centos/centos:centos7.9.2009...
Getting image source signatures
Copying blob 2d473b07cdd5 done  
Copying config 8652b9f0cb done  
Writing manifest to image destination
Storing signatures
8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf
[root@192 ~]# podman images
REPOSITORY             TAG             IMAGE ID      CREATED        SIZE
quay.io/centos/centos  centos7.9.2009  8652b9f0cb4c  23 months ago  212 MB
[root@192 ~]# podman run -itd 8652b9f0cb4c /bin/bash
791b073795ba3dc4a74872774354f06947e53ad21da5ea6e3a65f8df597a3946
[root@192 ~]# podman ps
CONTAINER ID  IMAGE                                 COMMAND     CREATED         STATUS             PORTS       NAMES
791b073795ba  quay.io/centos/centos:centos7.9.2009  /bin/bash   17 seconds ago  Up 11 seconds ago              nostalgic_stonebraker
[root@192 ~]# podman exec  -it 791b073795ba /bin/bash
[root@791b073795ba /]# ls
anaconda-post.log  bin  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@791b073795ba /]# 

2.3设置端口映射,设置密码,建立Xshell远程

[root@791b073795ba /]# exit
exit
[root@192 ~]# podman rm -f 791b073795ba 
WARN[0010] StopSignal SIGTERM failed to stop container nostalgic_stonebraker in 10 seconds, resorting to SIGKILL 
791b073795ba3dc4a74872774354f06947e53ad21da5ea6e3a65f8df597a3946
[root@192 ~]# podman ps
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES
[root@192 ~]# podman run -itd --name=centos -p 5000:22 8652b9f0cb4c /bin/bash
5402cc8caced8598a39121db98673d70b5ce947bd085feb212695d1c49048723
[root@192 ~]# podman ps
CONTAINER ID  IMAGE                                 COMMAND     CREATED         STATUS             PORTS                 NAMES
5402cc8caced  quay.io/centos/centos:centos7.9.2009  /bin/bash   55 seconds ago  Up 54 seconds ago  0.0.0.0:5000->22/tcp  centos
[root@192 ~]# podman exec -it centos /bin/bash
[root@5402cc8caced /]# yum install -y openssh*
[root@5402cc8caced /]# rpm -qa |grep -E "openssh"
openssh-askpass-7.4p1-22.el7_9.x86_64
openssh-server-sysvinit-7.4p1-22.el7_9.x86_64
openssh-ldap-7.4p1-22.el7_9.x86_64
openssh-7.4p1-22.el7_9.x86_64
openssh-cavs-7.4p1-22.el7_9.x86_64
openssh-clients-7.4p1-22.el7_9.x86_64
openssh-keycat-7.4p1-22.el7_9.x86_64
openssh-server-7.4p1-22.el7_9.x86_64

[root@5402cc8caced /]# whoami 
root
[root@5402cc8caced /]# echo 12345678|passwd --stdin root
Changing password for user root.
passwd: all authentication tokens updated successfully.
[root@5402cc8caced /]# 

启动sshd, 失败

systemctl start sshd

安装 initscripts

yum install initscripts

重启sshd服务

service sshd restart
#systemctl start sshd

Xshell连接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

醉里看星辰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值