• centos7更新podman


    实验环境:centos7.7.1908

    1.安装podman并查看版本

    yum install podman

    podman -v

     当前podman版本信息是1.6.4

    2.更新podman版本

    通过查看资料显示centos 7 支持最高版本为 3.4.4,更新podman大致有以下四步:

    1. golang 安装(本次使用版本: 1.18)
    2. conmon 安装(本次使用版本: 2.1.0)
    3. runc 安装(本次使用版本: 1.1.1)
    4. podman安装(centos 7支持最高版本: 3.4.4)

    下面先实验安装podman3.4.4,之后会实验安装当前最新版podman4.6.1

     2.1安装go
    1. # 临时关闭selinux
    2. setenforce 0
    3. # 安装golang,版本需要在 v1.6 以上
    4. wget https://golang.google.cn/dl/go1.18.linux-amd64.tar.gz
    5. tar xf go1.18.linux-amd64.tar.gz
    6. mv go /usr/local/
    7. ln -s /usr/local/go/bin/go /usr/local/bin/go
    8. go version
    9. # go version go1.18 linux/amd64

     

    安装依赖

    1. yum install -y \
    2. btrfs-progs-devel \
    3. containernetworking-plugins \
    4. containers-common \
    5. crun \
    6. device-mapper-devel \
    7. glib2-devel \
    8. glibc-devel \
    9. glibc-static \
    10. golang-github-cpuguy83-md2man \
    11. gpgme-devel \
    12. iptables \
    13. libassuan-devel \
    14. libgpg-error-devel \
    15. libseccomp-devel \
    16. libselinux-devel \
    17. make \
    18. pkgconfig
    2.2安装conmon 和 runc
    1. # conmon是用C语言编写的工具,用于单个容器的管理器
    2. wget https://github.com/containers/conmon/archive/refs/tags/v2.1.0.tar.gz
    3. tar xf v2.1.0.tar.gz
    4. cd conmon-2.1.0/
    5. export GOCACHE="$(mktemp -d)"
    6. make
    7. make podman
    8. #install -D -m 755 bin/conmon /usr/local/libexec/podman/conmon
    9. conmon --version
    10. #conmon version 2.0.8
    11. #commit: f85c8b1ce77b73bcd48b2d802396321217008762
    12. # runc是golang写的关于CLI工具,用于根据OCI规范在 Linux上生成和运行容器
    13. wget https://github.com/opencontainers/runc/releases/download/v1.1.1/runc.amd64
    14. chmod +x runc.amd64
    15. mv runc.amd64 /usr/local/bin/runc
    16. /usr/local/bin/runc -version
    17. #runc version 1.1.1
    18. #commit: v1.1.0-20-g52de29d7
    19. #spec: 1.0.2-dev
    20. #go: go1.17.6
    21. #libseccomp: 2.5.3

    上面是由于当前环境下没有gcc编译器造成的,要通过yum install gcc安装gcc

    之后重新执行 make 和 make podman 命令重新编译即可

    2.3设置CNI网络
    1. mkdir /etc/containers
    2. wget https://src.fedoraproject.org/rpms/containers-common/raw/main/f/registries.conf
    3. wget https://src.fedoraproject.org/rpms/containers-common/raw/main/f/default-policy.json
    4. cp default-policy.json /etc/containers/default-policy.json
    5. cp registries.conf /etc/containers/registries.conf
    6. # 默认情况下,CNI网络配置文件下载好后,无需配置,即可使用 podman
    7. # registries.conf: 容器镜像注册配置文件,文件格式为 TOML
    8. # policy.json:证书安全策略文件,文件格式为 JSON

    /etc/containers如果存在就不用创建了,不存在需要创建

    cp registries.conf /etc/containers/registries.conf命令如果containers文件夹存在的话registries.conf文件也会存在,直接替换即可

    2.4安装podman
    1. wget https://github.com/containers/podman/archive/refs/tags/v3.4.4.tar.gz
    2. tar xf v3.4.4.tar.gz
    3. cd podman-3.4.4/
    4. make BUILDTAGS="selinux seccomp"
    5. # 存在问题
    6. yum install git -y
    7. vim Makefile
    8. ####
    9. # 800行 github.com/cpuguy83/go-md2man 改为
    10. gitee.com/mirrors/go-md2man
    11. ####
    12. # 再次make
    13. make BUILDTAGS="selinux seccomp"
    14. make install PREFIX=/usr
    15. # 会自动在usr的bin、lib、share 中 创建相关内容
    16. podman --version
    17. # podman version 3.4.4
    18. podman version
    19. #Version: 3.4.4
    20. #API Version: 3.4.4
    21. #Go Version: go1.18
    22. #Built: Thu Sep 7 07:07:51 2023
    23. #OS/Arch: linux/amd64

     首次执行make BUILDTAGS="selinux seccomp"需要安装git以及在Makefile文件需要在800行进行修改,然后再次make

     

    然后我尝试了安装最新版podman4.6.1,操作基本与上面一致 

    wget https://golang.google.cn/dl/go1.21.1.linux-amd64.tar.gz

     wget https://github.com/containers/podman/archive/refs/tags/v4.6.1.tar.gz

    首次 make BUILDTAGS="selinux seccomp"编译

    安装git以后,再次make 

     [root@ee283976513d podman-4.6.1]# make BUILDTAGS="selinux seccomp"
    fatal: Not a git repository (or any of the parent directories): .git
    Podman is being compiled without the systemd build tag.         Install libsystemd on Ubuntu or systemd-devel on rpm based      distro for journald support.
    CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
             \
            -ldflags ' -X github.com/containers/podman/v4/libpod/define.buildInfo=1694077099 -X github.com/containers/podman/v4/libpod/config._installPrefix=/usr/local -X github.com/containers/podman/v4/libpod/config._etcDir=/etc -X github.com/containers/podman/v4/pkg/systemd/quadlet._binDir=/usr/local/bin -X github.com/containers/common/pkg/config.additionalHelperBinariesDir= ' \
            -tags "selinux seccomp" \
            -o bin/podman ./cmd/podman
    go build github.com/proglottis/gpgme:
    # pkg-config --cflags  -- gpgme
    Package gpgme was not found in the pkg-config search path.
    Perhaps you should add the directory containing `gpgme.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'gpgme' found
    pkg-config: exit status 1
    make: *** [bin/podman] Error 1

    之后通过wget https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-1.22.0.tar.bz2 

     tar -xvjf gpgme-1.22.0.tar.bz2

    按照前面更新podman到3.4.4版本的方式并不能成功更新podman到最新版,下一个博客我会介绍如何更新centos7的podman到最新版。

  • 相关阅读:
    R语言dplyr包distinct函数基于dataframe数据中的所有变量移除重复行
    Linux 提权-密码搜寻
    postfix+dovecot+SSL 搭建邮件服务器
    LeetCode刷题(python版)——Topic72. 编辑距离
    初识Layering Sequence
    深度剖析数据在内存中的存储
    【大数据折腾不息系列】(一) VMware虚拟机和CentOS Stream安装
    个人开源项目如何上传maven中央仓库
    【执行数据库操作时Tomcat报错但不影响使用】error testWhileIdle is true, validationQuery not set
    RabbitMQ高级篇,进阶内容
  • 原文地址:https://blog.csdn.net/m0_66570838/article/details/132739404