Linux Shell 实现一键部署podman

news2024/10/3 6:30:11

podman 介绍

使用 Podman 管理容器、Pod 和映像。从本地环境中无缝使用容器和 Kubernetes,Podman 提供与 Docker 非常相似的功能,它不需要在你的系统上运行任何守护进程,并且它也可以在没有 root 权限的情况下运行。

Podman 可以管理和运行任何符合 OCI(Open Container Initiative)规范的容器和容器镜像。Podman 提供了一个与 Docker 兼容的命令行前端来管理 Docker 镜像。

podman download

podmanpodman 文档gitlab开源podman ubuntu repo
download参考参考参考

创建一键部署脚本

  • 主要用于安装Podman容器引擎。脚本首先检查操作系统的版本,并根据不同的操作系统版本选择相应的安装方法。脚本支持CentOS、Red Hat、Oracle Linux、Rocky Linux、AlmaLinux、Ubuntu、Debian、Fedora和SUSE等多个发行版。
  • 使用yum包管理器安装Podman及其插件,并配置registries.conf文件。对于Ubuntu和Debian,使用apt包管理器安装Podman及其插件,并配置registries.conf文件。对于Fedora,使用dnf包管理器安装Podman及其插件。对于SUSE,使用zypper包管理器安装Podman及其插件。
  • podman --version | awk '{print $3}' #podman版本获取
  • podman-compose --version 2>&1 | awk 'NR==1{print $3}' #podman-compose 版本获取
  • podman-compose --version 2>&1 | head -n1 | awk '{print $NF}' #podman-compose 版本获取
  • podman --help 命令使用参考
vi /podman_install.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/09/18

<<!
# ubuntu To execute this script 
ln -sf bash /bin/sh
!

install_basics() {

# Check if the script is being run as root
if [ "$(id -u)" != "0" ]; then
  echo "This script must be run as root."
  exit 1
fi

  # Check the CentOS/Red Hat version
if [[ -f /etc/redhat-release ]]; then
    OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
    VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)

  # Check the oralce Linux version
elif [[ -f /etc/oracle-release ]]; then
    OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
    VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)

  # Check the Rock Linux version
elif [[ -f /etc/rocky-release ]]; then
  OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
  VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
  
  # Check the AlmaLinux version 
elif [[ -f /etc/almalinux-release ]]; then
  OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
  VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)

  # Check the ubuntu version
elif [[ -f /etc/os-release ]]; then
	OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
    VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)

  # Check the suse version
elif [[ -f /etc/SuSE-release ]]; then
    OS=$( cat /etc/*release* | grep "^PRETTY_NAME=" | cut -d'=' -f2- | tr -d '"')
    VERSION=$(cat /etc/*release* | grep -oE '[0-9]+\.[0-9]+' | head -n1)
	
  # Check the Debian version
elif [[ -f /etc/os-release ]]; then
  OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
  VERSION=$(cat /etc/*release* | grep -oE '[0-9]+' | head -n1)
	
  # Check the Fedora version
elif [[ -f /etc/fedora-release ]]; then
  OS=$(cat /etc/*release* | grep "^NAME=" | cut -d'=' -f2- | tr -d '"')
  VERSION=$(cat /etc/*release* | grep -oE '[0-9]+' | head -n1)

else
  echo -e "\033[31mThis script only supports $OS $VERSION...\033[0m"
  exit 1
fi

# Check the podman version
if ! command -v podman &> /dev/null; then
#if [ ! -d "/usr/bin/podman" ]; then
  echo -e "\033[32m Installing podman for $OS $VERSION...\033[0m"
  case $VERSION in
 
# CentOS/RedHat/oracle 7 install
    7.?)
	echo Installing basics...
	install_centos_podman
   ;;

# CentOS/RedHat/oracle/RockLinux/AlmaLinux 8 install 
    8.?)
	echo Installing basics...
	install_centos_podman
   ;;

# CentOS/RedHat/oracle/RockLinux/AlmaLinux 9 install
   9.?) 
	echo Installing basics...
	install_centos_podman
   ;;
   
  # ubuntu 20.04 Linux install
   20.04)
	echo Installing basics...
	echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
	curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04/Release.key" | sudo apt-key add -
	apt update
	install_ubuntu_podman
   ;;

 # ubuntu 21 Linux install
   21.04|21.10)
	echo Installing basics...
	echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_21.04/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
	curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_21.04/Release.key" | sudo apt-key add -
	apt update
	install_ubuntu_podman
   ;;

 # ubuntu 22 Linux install
   22.04)
	echo Installing basics...
	echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_22.04/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
	curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_22.04/Release.key" | sudo apt-key add -
	apt update
	install_ubuntu_podman
   ;;
  
  # Debian 10, 11 , 12
  10)
   echo Installing basics...
   	echo Installing basics...
	echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_10/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
	curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_10/Release.key" | sudo apt-key add -
	apt update
	install_ubuntu_podman
   ;;
   
   11)
   echo Installing basics...
   	echo Installing basics...
	echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_11/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
	curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_11/Release.key" | sudo apt-key add -
	apt update
	install_ubuntu_podman
   ;;
   
  12)
   echo Installing basics...
   	echo Installing basics...
	echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_12/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
	curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/Debian_12/Release.key" | sudo apt-key add -
	apt update
	install_ubuntu_podman
   ;;
   
   
  # Fedora 31,32,33
  36|37|38)
   	echo Installing basics...
   install_centos_podman
   ;;

  # SUSE 12 install
  12.?)
	echo Installing  basics...
	sudo SUSEConnect -p sle-sdk/12.4/x86_64
	install_suse_podman
   ;;

  # SUSE 15 install
  15.?)
	echo Installing  basics...
	sudo SUSEConnect -p sle-sdk/15.3/x86_64
	install_suse_podman
   ;;
    *)
	
    echo -e "\033[31m Unsupported $OS $VERSION...\033[0m" 
    exit 1
    ;;
esac
	
    echo -e "\033[32m podman for $OS $VERSION successfully installed...\033[0m"
else
    echo -e "\033[33m podman for $OS $VERSION already installed...\033[0m"
fi

}

install_centos_podman() {
echo "install podman"
yum -y install podman podman-plugins podman-docker python3
pip3 install podman-compose

#registries.conf add config
cat >>/etc/containers/registries.conf<<EOF
[registries_search]
registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
EOF

podman info

# start podman
systemctl enable --now podman

#check podman version
podman --version | awk '{print $3}'
podman-compose --version 2>&1 | head -n1 | awk '{print $NF}'
}

install_ubuntu_podman() {
echo "install podman"
apt -y install podman podman-plugins python3 python3-pip
pip3 install podman-compose

cat >>/etc/containers/registries.conf<<EOF
[registries_search]
registries=["registry.access.redhat.com", "registry.fedoraproject.org", "docker.io"]
EOF

podman info

# start podman
systemctl enable --now podman


#check podman version
podman --version | awk '{print $3}'
podman-compose --version 2>&1 | head -n1 | awk '{print $NF}'

}

install_suse_podman() {
echo "install podman"
sudo zypper in -y podman net-tools vim wget net-tools
}

main (){
	install_basics
}

main

执行一键安装podman 

sh /podman_install.sh

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1024414.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

JavaWeb后端开发登录操作 登录功能 通用模板/SpringBoot整合

登录功能的思路 前端会传入两个参数:用户名和密码 在用户表中查询用户名,并校对相应的密码(涉及查询操作) SQL语句 select * from emp where username jingyong and password 123456; 如果有则成功,没有则登录失败.不可能为多个,因为添加了unique唯一约束,最终只会有一条 …

如何将转换器应用于时序模型

一、说明 在机器学习的广阔环境中&#xff0c;变压器作为建筑奇迹屹立不倒&#xff0c;以其复杂的设计和捕获复杂关系的能力重塑了我们处理和理解大量数据的方式。 自 2017 年创建第一台变压器以来&#xff0c;变压器类型呈爆炸式增长&#xff0c;包括强大的生成 AI 模型&#…

Kubernetes部署dolphindcheduler-3.1.8问题记录

温故知新 ⁉️问题记录❓问题一&#xff1a;Unschedulable 0/3 nodes are available: pod has unbound immediate PersistentVolumeClaims. preemption: 0/3 nodes are available: 3 No preemption victims found for incoming pod..❗解决方式&#xff1a;创建PV供应&#x1f…

ARM Soc内部总线

由于soc架构&#xff0c;把常用外设&#xff08;控制器&#xff09;集成到芯片内部&#xff0c;所以需要一种总线协调ARMcore与这些内部外设的通信&#xff0c;于是有了APB and AHB以及AXi这种片上总线。 同时要注意与常说的PC时代总线区分开&#xff1a; CPU总线&#xff08;…

刷题笔记24——完全二叉树的节点个数

有些事情是不能告诉别人的,有些事情是不必告诉别人的,有些事情是根本没有办法告诉别人的,而且有些事情是,即使告诉了别人,你也会马上后悔的。——罗曼罗兰 222. 完全二叉树的节点个数 java的幂运算要 (int) Math.pow(2,l1)-1计算满二叉树的节点数量公式&#xff1a;2 ^ height…

【面试题】—— Java多线程篇(17题)

文章目录 1.什么是多线程&#xff1f;2.线程和进程的区别&#xff1f;3.我们为什么要使用线程&#xff1f;线程的优缺点&#xff1f;4.创建线程的方法有哪些&#xff1f;5.线程的状态有哪些&#xff1f;6.线程的优先级&#xff1f;7.线程常用的方法以及其作用&#xff1f;8.使用…

穿越撒哈拉:中国跨境电商的非洲冒险之旅

非洲&#xff0c;这片古老而神秘的大陆&#xff0c;一直以来都是探险者和冒险家的梦想之地。然而&#xff0c;近年来&#xff0c;中国的跨境电商企业也开始将目光投向了这片充满机遇的土地&#xff0c;但他们的目标不再是黄金和珍宝&#xff0c;而是一个更为宝贵的财富&#xf…

创建线程的方式打开记事本

更好的阅读体验 \huge{\color{red}{更好的阅读体验}} 更好的阅读体验 今天操作系统课老师讲到进程&#xff0c;提出了一个有趣的小实验&#xff1a;能否以系统调用的方式利用 Windows 创建进程的系统调用函数来打开一个软件。闲着蛋疼的我立马来了兴趣&#xff0c;姑且写一个玩…

跨平台编程开发工具Xojo 2023 Release mac中文版功能介绍

Xojo mac是一款跨平台的软件开发工具&#xff0c;它允许开发人员使用一种编程语言来创建应用程序&#xff0c;然后可以在多个操作系统上运行。Xojo 2023是Xojo开发工具的最新版本&#xff0c;它提供了许多功能和改进&#xff0c;以帮助开发人员更轻松地构建高质量的应用程序。 …

【洛谷】P2004 领地选择

原题链接&#xff1a;https://www.luogu.com.cn/problem/P2004 目录 1. 题目描述 2. 思路分析 3. 代码实现 1. 题目描述 2. 思路分析 整体思路&#xff1a;二维前缀和 &#xff08;模板在这https://blog.csdn.net/m0_62531913/article/details/132712831?spm1001.2014.30…

[安洵杯 2019]easy_web md5强碰撞 preg_match绕过

比较简单 url一看就存在一个cmd 和 base64 我们尝试给cmd传递参数 但是没有效果 所以我们就去看看 img里面是什么 直接放到瑞士军刀看看 知道了加密方法 我们去看看能不能返回 index.php代码 TmprMlpUWTBOalUzT0RKbE56QTJPRGN3 返回了 接下俩就是代码审计了 <?php erro…

Python ---使用Fake库向clickhouse造数据小案例

每次insert太麻烦了 先在clickhosue中建表 test_user表 CREATE TABLE dwh.test_user (name String,age Int32,address String,phone String,email String ) ENGINE MergeTree() ORDER BY name; 此时表中暂无数据 用Python脚本来造一些数据 from faker import Faker from c…

Matlab图像处理-灰度级到彩色空间变换法

灰度级到彩色空间变换法 灰度图像转换为具有多种颜色渐变的连续彩色图像。该方法的基本概念是对任意输入像素的灰度级进行三个独立的变换。然后&#xff0c;将三个变换结果分别发送到彩电电视监视器的红、绿、蓝通道。该方法产生一个合成图像&#xff0c;其彩色内容受变换函数…

地球+卫星运动轨迹

由于工作中&#xff0c; 需要追踪卫星&#xff0c; 记录一下最近的工作成果&#xff0c; 分别有俩个方案&#xff0c; 一个是基于市面上主流的Threejs&#xff0c; 另外一个是基于Cesium&#xff0c; 还尝试过使用&#xff0c; Planetary.js&#xff0c; 效果其实还蛮好&#x…

vSphere 7.0 Update 3提示vCLS虚拟机没有兼容的主机的问题即物理机开启CPU “Monitor/Mwait”功能的方法

本文讲解在华为物理服务器上开启CPU "Monitor/Mwait"功能的方法&#xff0c;以解决vSphere 7.0 Update 3平台上vCLS代理虚拟机提示没有与虚拟机兼容的主机&#xff0c;无法开机&#xff0c;且一直尝试启动反复告警的问题。 一、问题实况 1、VC升级到7.0.3后&#x…

Linux系统编程(三):进程

参考引用 UNIX 环境高级编程 (第3版)黑马程序员-Linux 系统编程 1. 进程相关概念 1.1 程序和进程 程序&#xff0c;是指编译好的二进制文件&#xff0c;在磁盘上&#xff0c;不占用系统资源 (CPU、内存、打开的文件、设备、锁…) 程序 → 剧本 (纸) 进程与操作系统原理联系紧…

基于Yolov8的野外烟雾检测(3):动态蛇形卷积(Dynamic Snake Convolution),实现暴力涨点 | ICCV2023

目录 1.Yolov8介绍 2.野外火灾烟雾数据集介绍 3.Dynamic Snake Convolution 3.1 Dynamic Snake Convolution加入到yolov8 4.训练结果分析 5.系列篇 1.Yolov8介绍 Ultralytics YOLOv8是Ultralytics公司开发的YOLO目标检测和图像分割模型的最新版本。YOLOv8是一种尖端的、最…

ggplot2做图(填坑中)

数据 df <- data.frame(x 1:10, y 1:10, f c(rep("A", 5), rep("B", 5))) 做图 1. 散点图 (scatter plot) # scatter plot scatter_plot <- function(df, metadata) {identical(rownames(df), rownames(metadata))data <- cbind(df, metada…

JavaScript系列从入门到精通系列第一篇:JavaScript语言简介和它代码初体验

一&#xff1a;简介 1&#xff1a;起源 JavaScript诞生于1995年&#xff0c;它的出现主要是用于处理网页中的前端验证&#xff0c; 所谓的前端验证&#xff0c;就是指检查用户输入的内容是否符合一定的规则。 2&#xff1a;简史 JavaScript是由网景公司发明&#xff0c;起初命…

安全测试:文件上传漏洞检测

文件上传漏洞 是一种安全漏洞&#xff0c;允许攻击者将恶意文件上传到目标服务器&#xff0c;从而可能导致恶意代码执行、服务器瘫痪或其他不安全的情况。 假设您正在测试一个网络应用程序&#xff0c;该应用程序允许用户上传文件&#xff0c;例如用户头像。你怀疑应用程序可能…