首页 > 其他分享 >podman的部署与应用

podman的部署与应用

时间:2022-08-14 23:27:00浏览次数:54  
标签:ago io 部署 podman 应用 node1 docker root

目录


部署podman

安装podman

[root@node1 ~]# yum -y install podman
Last metadata expiration check: 8:06:25 ago on Sun 14 Aug 2022 11:58:39 AM CST.
Package podman-3.3.1-9.module_el8.5.0+988+b1f0b741.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

配置podman加速器

[root@node1 ~]# vim /etc/containers/registries.conf
[[registry]]
prefix = "docker.io"
location = "docker.mirrors.ustc.edu.cn"

podman的应用

拉取httpd镜像

[root@node1 ~]# podman pull httpd
Resolving "httpd" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
Copying blob dcc4698797c8 done  
Copying blob d982c879c57e done  
Copying blob a2abf6c4d29d done  
Copying blob 67283bbdd4a0 done  
Copying blob 41c22baa66ec done  
Copying config dabbfbe0c5 done  
Writing manifest to image destination
Storing signatures
dabbfbe0c57b6e5cd4bc089818d3f664acfad496dc741c9a501e72d15e803b34

列出镜像

[root@node1 ~]# 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
quay.io/centos/centos      latest      300e315adb2f  20 months ago  217 MB

进入liu这个容器

[root@node1 ~]# podman attach liu
[root@3f094fbabd87 /]# 

提交容器

[root@node1 ~]# podman commit -p liu
Getting image source signatures
Copying blob 2653d992f4ef skipped: already exists  
Copying blob b7d2d260599a done  
Copying config 6a01de1247 done  
Writing manifest to image destination
Storing signatures
6a01de12470bb84beadd6402bfff55914dbe6efcd6e1cc4165ffb143d9f8c006

将本机的内容复制到容器中

[root@node1 ~]# podman ps
CONTAINER ID  IMAGE                             COMMAND     CREATED         STATUS                 PORTS       NAMES
b1958f65a72d  docker.io/library/busybox:latest  sh          2 minutes ago   Up About a minute ago              liu
af315e214ea2  docker.io/library/busybox:latest  sh          14 seconds ago  Up 13 seconds ago                  ly
[root@node1 ~]# ls
anaconda-ks.cfg  html  php-7.4.30.tar.xz  remi-release-7.rpm  wget-log
[root@node1 ~]# podman cp html/ af315e214ea2:/
/ # ls
bin   dev   etc   home  html  proc  root  run   sys   tmp   usr   var

创建一个容器

[root@node1 ~]# podman create -it --name aaa busybox
cd32b04d381e8e8d44a8622558e376c1caf1b08fa037e5eab356102110262376

查看liu这个容器的历史动作

[root@node1 ~]# podman diff liu
C /etc
C /root
A /root/.ash_history

进入liu这个容器

[root@node1 ~]# podman ps
CONTAINER ID  IMAGE                             COMMAND     CREATED        STATUS            PORTS       NAMES
b1958f65a72d  docker.io/library/busybox:latest  sh          8 minutes ago  Up 8 minutes ago              liu
af315e214ea2  docker.io/library/busybox:latest  sh          6 minutes ago  Up 6 minutes ago              ly
[root@node1 ~]# podman exec -it b1958f65a72d /bin/sh
/ # 

将ly这个容器导入到ly.tar这个归档中

[root@node1 ~]# podman export ly > ly.tar

为ly容器生成systemd单元文件

[root@node1 ~]# podman generate systemd --new --files --name ly
/root/container-ly.service

查看busybox镜像的历史动作

[root@node1 ~]# podman history busybox
ID            CREATED       CREATED BY                                     SIZE        COMMENT
beae173ccac6  7 months ago  /bin/sh -c #(nop)  CMD ["sh"]                  0 B         
<missing>     7 months ago  /bin/sh -c #(nop) ADD file:6db446a57cbd2b7...  1.46 MB   

列出所有镜像的两种方式、

[root@node1 ~]# podman image ls
REPOSITORY                 TAG         IMAGE ID      CREATED       SIZE
docker.io/library/busybox  latest      beae173ccac6  7 months ago  1.46 MB
[root@node1 ~]# podman images
REPOSITORY                 TAG         IMAGE ID      CREATED       SIZE
docker.io/library/busybox  latest      beae173ccac6  7 months ago  1.46 MB

导入ly.tar这个包

[root@node1 ~]# podman import ly.tar 
Getting image source signatures
Copying blob e704a424c5b3 done  
Copying config 5bfedc8d55 done  
Writing manifest to image destination
Storing signatures
sha256:5bfedc8d55957ff77e15156876525ec7798172df4eeac7cc39c2a5f4300bfd0d

查看基本信息

[root@node1 ~]# podman info  |head -4
host:
  arch: amd64
  buildahVersion: 1.22.3
  cgroupControllers:

初始化aaa这个容器

[root@node1 ~]# podman init aaa 
cd32b04d381e8e8d44a8622558e376c1caf1b08fa037e5eab356102110262376

查看aaa这个容器的详细信息

[root@node1 ~]# podman  inspect aaa |head -8
[
    {
        "Id": "cd32b04d381e8e8d44a8622558e376c1caf1b08fa037e5eab356102110262376",
        "Created": "2022-08-14T21:34:07.770011917+08:00",
        "Path": "sh",
        "Args": [
            "sh"
        ],

杀死ly这个容器

[root@node1 ~]# podman kill ly
ly

登入容器仓库

[root@node1 ~]# podman login
Authenticating with existing credentials for docker.io
Existing credentials are valid. Already logged in to docker.io

登出容器仓库

//因为没有redhat账户所以登入不进去
[root@node1 ~]# podman logout
^C[root@node1 ~]# podman logout docker.io
Not logged into docker.io with current tool. Existing credentials were established via docker login. Please use docker logout instead.

查看ly这个容器的日志

[root@node1 ~]# podman  logs ly
/ # ls
bin   dev   etc   home  html  proc  root  run   sys   tmp   usr   var

查看网络模式

[root@node1 ~]# podman network ls
NETWORK ID    NAME        VERSION     PLUGINS
2f259bab93aa  podman      0.4.0       bridge,portmap,firewall,tuning

暂停liu这个容器的所有进程

[root@node1 ~]# podman pause liu
b1958f65a72d794bcb08f8222cd0e37ebff2b193e500a732688c1f77155bac69

查看正在运行的容器

[root@node1 ~]# docker ps
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
CONTAINER ID  IMAGE       COMMAND     CREATED     STATUS      PORTS       NAMES

挂载这个容器的根文件系统

[root@node1 ~]# podman mount  b1958f65a72d
/var/lib/containers/storage/overlay/6d53f7ea803906a9be31576721b4df21b948532d5ec821306a4e23cabca07c2b/merged

给容器重命名

[root@node1 ~]# podman  ps -a
CONTAINER ID  IMAGE                             COMMAND     CREATED            STATUS                       PORTS       NAMES
b1958f65a72d  docker.io/library/busybox:latest  sh          About an hour ago  paused                                   liu
af315e214ea2  docker.io/library/busybox:latest  sh          About an hour ago  Exited (137) 37 minutes ago              ly
cd32b04d381e  docker.io/library/busybox:latest  sh          About an hour ago  created                                  aaa
[root@node1 ~]# podman  rename ly LY
[root@node1 ~]# podman  ps -a
CONTAINER ID  IMAGE                             COMMAND     CREATED            STATUS                       PORTS       NAMES
b1958f65a72d  docker.io/library/busybox:latest  sh          About an hour ago  paused                                   liu
af315e214ea2  docker.io/library/busybox:latest  sh          About an hour ago  Exited (137) 38 minutes ago              LY
cd32b04d381e  docker.io/library/busybox:latest  sh          About an hour ago  created                                  aaa

重启LY这个容器

[root@node1 ~]# podman  restart LY
af315e214ea236bb0c143f32aa91fb270a83591deeaef6c42164a5bd022797d3

删除liu这个容器 -f强制删除

[root@node1 ~]# podman rm -f liu
b1958f65a72d794bcb08f8222cd0e37ebff2b193e500a732688c1f77155bac69

删除镜像

[root@node1 ~]# podman  rmi -f beae173ccac6
Untagged: docker.io/library/busybox:latest
Deleted: beae173ccac6ad749f76713cf4440fe3d21d1043fe616dfbe30775815d1d0f6a

创建并启动一个容器

[root@node1 ~]# podman  run --name lll -it httpd /bin/bash
Resolving "httpd" using unqualified-search registries (/etc/containers/registries.conf)
Trying to pull docker.io/library/httpd:latest...
Getting image source signatures
Copying blob 67283bbdd4a0 done  
Copying blob d982c879c57e done  
Copying blob dcc4698797c8 done  
Copying blob a2abf6c4d29d done  
Copying blob 41c22baa66ec done  
Copying config dabbfbe0c5 done  
Writing manifest to image destination
Storing signatures
root@16f20c12a43e:/usr/local/apache2# 

将httpd镜像保存到lll这个tar包中

[root@node1 ~]# podman  save httpd > lll.tar

搜索httpd镜像来自哪个仓库

[root@node1 ~]# podman  search httpd
INDEX       NAME                                             DESCRIPTION                                      STARS       OFFICIAL    AUTOMATED
docker.io   docker.io/library/httpd                          The Apache HTTP Server Project                   4116        [OK]        
docker.io   docker.io/clearlinux/httpd                       httpd HyperText Transfer Protocol (HTTP) ser...  2                       
docker.io   docker.io/centos/httpd-24-centos7                Platform for running Apache httpd 2.4 or bui...  44                      
docker.io   docker.io/manageiq/httpd                         Container with httpd, built on CentOS for Ma...  1                       [OK]

启动lll这个容器

[root@node1 ~]# podman  start lll
lll

暂停lll这个容器

[root@node1 ~]# podman  stop lll
lll

查看系统的基本信息

[root@node1 ~]# podman  system info
host:
  arch: amd64
  buildahVersion: 1.22.3
  cgroupControllers:
  - cpuset

给镜像定义名称

[root@node1 ~]# podman images
REPOSITORY               TAG         IMAGE ID      CREATED            SIZE
<none>                   <none>      5bfedc8d5595  About an hour ago  1.6 MB
docker.io/library/httpd  latest      dabbfbe0c57b  7 months ago       148 MB
[root@node1 ~]# podman  tag  5bfedc8d5595 docker.io/library/httpd:1.1 
[root@node1 ~]# podman  images
REPOSITORY               TAG         IMAGE ID      CREATED            SIZE
docker.io/library/httpd  1.1         5bfedc8d5595  About an hour ago  1.6 MB
docker.io/library/httpd  latest      dabbfbe0c57b  7 months ago       148 MB

显示lll容器的运行进程

[root@node1 ~]# podman  top lll
USER        PID         PPID        %CPU        ELAPSED        TTY         TIME        COMMAND
root        1           0           0.000       12.005043792s  pts/0       0s          /bin/bash 

卸载容器的根文件系统

[root@node1 ~]# podman unmount 16f20c12a43e 
16f20c12a43e

重新暂停lll这个容器

[root@node1 ~]# podman  unpause lll
16f20c12a43ec93c607da43c01719a668b6c37dce5d66aba085ea708521db3f1

删除镜像的名称

[root@node1 ~]# podman  images
REPOSITORY               TAG         IMAGE ID      CREATED            SIZE
docker.io/library/httpd  1.1         5bfedc8d5595  About an hour ago  1.6 MB
docker.io/library/httpd  latest      dabbfbe0c57b  7 months ago       148 MB
[root@node1 ~]# podman  untag  5bfedc8d5595
[root@node1 ~]# podman  images
REPOSITORY               TAG         IMAGE ID      CREATED            SIZE
<none>                   <none>      5bfedc8d5595  About an hour ago  1.6 MB
docker.io/library/httpd  latest      dabbfbe0c57b  7 months ago       148 MB

显示podman版本号

[root@node1 ~]# podman  version 
Version:      3.3.1
API Version:  3.3.1
Go Version:   go1.16.7
Built:        Wed Nov 10 05:23:56 2021
OS/Arch:      linux/amd64

查看卷

[root@node1 ~]# podman  volume ls
[root@node1 ~]# 

阻塞lll这个容器

[root@node1 ~]# podman wait lll

标签:ago,io,部署,podman,应用,node1,docker,root
From: https://www.cnblogs.com/TQingS/p/16586660.html

相关文章

  • 现代企业架构框架-应用架构
    现代企业架构框架:https://mp.weixin.qq.com/s/SlrEu0_t0slijrNZ6DP4Ng业务架构:https://mp.weixin.qq.com/s/zQCjiHuxFvAg5QiOAuLAcQ4.应用架构应用架构的核心关注点......
  • 数组应用!!!
    稀疏数组类似棋盘上的棋子:用二维数组保存:用稀疏数组来保存:publicclassXiShu{publicstaticvoidmain(String[]args){//创造二维数组i......
  • 02-Spark的应用及使用
    应用场景离线场景:实现离线数据仓库中的数据清洗、数据分析、即席查询等应用比较成熟,工作中主要的应用场景使用Spark对各种数据源数据进行处理:Hive、RDBMS、文件Hive......
  • Linux下部署Kubernetes+Kubesphere(一)Kubernetes基础
    Linux下部署Kubernetes+Kubesphere(一)Kubernetes基础Cloud研习社 2022-07-0318:36 发表于山东 以下文章来源于Dotnet技术进阶 ,作者车神neDotnet技术进阶..Ne......
  • pxe网络装机与实战部署
    干货|PXE+kickstart无人值守批量装机(原理与架构)原创 Cloud研习社 Cloud研习社 2022-06-2813:33 发表于山东收录于合集#一站式教程119个#实战经验31个#lin......
  • Java基础的简单应用
    packagecom.zhou.partise;importjava.util.Scanner;publicclassTest01{publicstaticvoidmain(String[]args){//写一个计算器,要求实现加减乘除功能,并......
  • centos7使用 Docker Engine部署gitlab
    1.安装docker-ce卸载旧版本:yumremovedockerdocker-commondocker-selinuxdocker-engine一、虚拟机联网,安装yum工具执行以下命令yuminstall-yyum-utils\dev......
  • C++ while/for循环的简单应用 1到100相加
    1.while循环:#include<iostream>usingnamespacestd;intmain(){intb=1;intsum=0;while(b<101){sum+=b;b++;......
  • (Docker)镜像的制作与部署方式
    基于Linux的虚拟化(Docker)镜像的制作与部署方式原创 曹兆祺 风乍起带你学编程 2022-08-1323:00 发表于天津收录于合集#docker5个#镜像1个#linux3个  ......
  • MinimalAPI---部署项目到IIS
    1.安装IIS,详情见:https://product.pconline.com.cn/itbk/vedio/1903/12395139.html2.安装ASP.NETCore运行时环境和程序包下载HostingBundle文件 安装包下载地址:https......