podman部署及应用

podman部署及应用

[root@localhost ~]# dnf -y install podman-docker
配置podman镜像加速器
[root@localhost ~]# cd /etc/containers/
[root@localhost containers]# ls
certs.d  policy.json      registries.conf.d  storage.conf
oci      registries.conf  registries.d
[root@localhost containers]# 
[root@localhost containers]# vim registries.
#lified-search-registries = ["registry.fedoraproject.org", "registry.access.redhat.com", "registry.centos.org", "docker.io"] //将此行注释掉
unqualified-search-registries = ["docker.io"]  //添加此行

[[registry]]
prefix = "docker.io"
location = "docker.mirrors.ustc.edu.cn"

测试拉取镜像
[root@localhost ~]# docker pull httpd
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Resolving "httpd" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
Copying blob d982c879c57e done  
Copying blob dcc4698797c8 done  
Copying blob a2abf6c4d29d done  
Copying blob 41c22baa66ec done  
Copying blob 67283bbdd4a0 done  
Copying config dabbfbe0c5 done  
Writing manifest to image destination
Storing signatures
dabbfbe0c57b6e5cd4bc089818d3f664acfad496dc741c9a501e72d15e803b34
[root@localhost ~]# podman pull httpd
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
Copying blob d982c879c57e skipped: already exists  
Copying blob dcc4698797c8 skipped: already exists  
Copying blob a2abf6c4d29d skipped: already exists  
Copying blob 41c22baa66ec skipped: already exists  
Copying blob 67283bbdd4a0 [--------------------------------------] 0.0b / 0.0b
Copying config dabbfbe0c5 done  
Writing manifest to image destination
Storing signatures
dabbfbe0c57b6e5cd4bc089818d3f664acfad496dc741c9a501e72d15e803b34
[root@localhost ~]# podman images
REPOSITORY               TAG         IMAGE ID      CREATED       SIZE
docker.io/library/httpd  latest      dabbfbe0c57b  7 months ago  148 MB
[root@localhost ~]# docker images
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
REPOSITORY               TAG         IMAGE ID      CREATED       SIZE
docker.io/library/httpd  latest      dabbfbe0c57b  7 months ago  148 MB
[root@localhost ~]# 
#上面拉取镜像过程中发现拉取centos镜像时,默认在红帽镜像仓库拉取,若想自定义仓库拉取在拉取时将仓库地址写明即可
[root@localhost ~]# podman pull docker.io/library/httpd/centos

podman应用

[root@localhost ~]# podman search busybox //查找第一个容器镜像
INDEX       NAME                                         DESCRIPTION                                      STARS       OFFICIAL    AUTOMATED
docker.io   docker.io/library/busybox                    Busybox base image.                              2712        [OK]        
docker.io   docker.io/rancher/busybox                                                                     0                       
docker.io   docker.io/ibmcom/busybox                                                                      0                       
docker.io   docker.io/openebs/busybox-client                                                              0                       
docker.io   docker.io/antrea/busybox                                                                      0                       
docker.io   docker.io/ibmcom/busybox-amd64                                                                0                       
docker.io   docker.io/ibmcom/busybox-ppc64le                                                              0                       
docker.io   docker.io/yauritux/busybox-curl              Busybox with CURL                                16                      
docker.io   docker.io/vukomir/busybox                    busybox and curl                                 1                       
docker.io   docker.io/radial/busyboxplus                 Full-chain, Internet enabled, busybox made f...  49                      [OK]
docker.io   docker.io/odise/busybox-curl                                                                  4                       [OK]
docker.io   docker.io/arm64v8/busybox                    Busybox base image.                              4                       
docker.io   docker.io/amd64/busybox                      Busybox base image.                              0                       
docker.io   docker.io/p7ppc64/busybox                    Busybox base image for ppc64.                    2                       
docker.io   docker.io/busybox42/zimbra-docker-centos     A Zimbra Docker image, based in ZCS 8.8.9 an...  2                       [OK]
docker.io   docker.io/joeshaw/busybox-nonroot            Busybox container with non-root user nobody      2                       
docker.io   docker.io/s390x/busybox                      Busybox base image.                              2                       
docker.io   docker.io/ppc64le/busybox                    Busybox base image.                              1                       
docker.io   docker.io/arm32v7/busybox                    Busybox base image.                              10                      
docker.io   docker.io/prom/busybox                       Prometheus Busybox Docker base images            2                       [OK]
docker.io   docker.io/busybox42/alpine-pod                                                                0                       
docker.io   docker.io/spotify/busybox                    Spotify fork of https://hub.docker.com/_/bus...  1                       
docker.io   docker.io/i386/busybox                       Busybox base image.                              3                       
docker.io   docker.io/busybox42/haraka-docker-centos     CentOS Haraka build with spamassassin, redis...  1                       [OK]
docker.io   docker.io/busybox42/nginx_php-docker-centos  This is a nginx/php-fpm server running on Ce...  1                       [OK]
[root@localhost ~]# 

运行和退出busybox镜像

[root@localhost ~]#  podman run -it docker.io/library/busybox
/ # hostname
0850f917a648
/ # exit
[root@localhost ~]# 

命令

# attach 进入到正在运行的容器
[root@localhost ~]# podman ps
CONTAINER ID  IMAGE                           COMMAND     CREATED             STATUS                 PORTS       NAMES
0850f917a648  docker.io/library/httpd:latest  /bin/bash   About a minute ago  Up About a minute ago              httpd
[root@localhost ~]# podman attach 0850f917a648
root@0850f917a648:/usr/local/apache2# exit
exit
# auto-update 根据容器的自动更新策略自动更新容器

# build 使用容器文件中的说明构建镜像

# commit 基于已更改的容器创建镜像
[root@localhost ~]# podman run -it busybox
/ # ls
bin   dev   etc   home  proc  root  run   sys   tmp   usr   var
/ # 
create 创建但不启动容器
[root@localhost ~]# podman create --name web httpd
a3708aa6b820974250c61331713a8cda47769c2ea53e51041fbc200bc3b2a50f
[root@localhost ~]# 
# history 显示指定图像的历史记录
[root@localhost ~]# podman history httpd
ID            CREATED       CREATED BY                                     SIZE              COMMENT
dabbfbe0c57b  7 months ago  /bin/sh -c #(nop)  CMD ["httpd-foreground"]    0 B               
<missing>     7 months ago  /bin/sh -c #(nop)  EXPOSE 80                   0 B               
<missing>     7 months ago  /bin/sh -c #(nop) COPY file:c432ff61c4993e...  3.58 kB           
<missing>     7 months ago  /bin/sh -c #(nop)  STOPSIGNAL SIGWINCH         0 B               
<missing>     7 months ago  /bin/sh -c set -eux;                                             savedAptMark="$(apt...  61.1 MB     
<missing>     7 months ago  /bin/sh -c #(nop)  ENV HTTPD_PATCHES=          0 B               
<missing>     7 months ago  /bin/sh -c #(nop)  ENV HTTPD_SHA256=0127f7...  0 B               
<missing>     7 months ago  /bin/sh -c #(nop)  ENV HTTPD_VERSION=2.4.52    0 B               
<missing>     7 months ago  /bin/sh -c set -eux;                           apt-get update;   apt...      2.72 MB     
<missing>     7 months ago  /bin/sh -c #(nop) WORKDIR /usr/local/apache2   0 B               
<missing>     7 months ago  /bin/sh -c mkdir -p "$HTTPD_PREFIX"            && ch...          3.07 kB     
<missing>     7 months ago  /bin/sh -c #(nop)  ENV PATH=/usr/local/apa...  0 B               
<missing>     7 months ago  /bin/sh -c #(nop)  ENV HTTPD_PREFIX=/usr/l...  0 B               
<missing>     7 months ago  /bin/sh -c #(nop)  CMD ["bash"]                0 B               
<missing>     7 months ago  /bin/sh -c #(nop) ADD file:09675d11695f65c...  83.9 MB           
[root@localhost ~]# 
# image 管理图像
[root@localhost ~]# podman images
REPOSITORY                 TAG         IMAGE ID      CREATED       SIZE
docker.io/library/busybox  latest      beae173ccac6  7 months ago  1.46 MB
docker.io/library/httpd    latest      dabbfbe0c57b  7 months ago  148 MB
[root@localhost ~]# 
posted @   niebangrui  阅读(138)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示