前言


记录podman的安装、配置以及一些常用操作,会不定时更新;

正文


1. podman 安装以及配置

ubuntu 安装 podman

sudo apt update
sudo apt install podman -y

podman配置国内镜像源

cd /etc/containers/
mv registries.conf registries.conf-bak
touch registries.conf

使用vim等编辑器编辑registries.conf:

unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
insecure = false
blocked = false
location = "docker.io"
[[registry.mirror]]
# location = "j3m2itm3.mirror.aliyuncs.com"
location = "docker.mirrors.ustc.edu.cn"

配置日志大小

cd /etc/containers/
touch containers.conf
# 编辑containers.conf内容如下 (日志大小10M,根据需求修改)
[containers]
log_size_max=10485760

2. podman常用指令

podman指令兼容docker指令,镜像也能用docker镜像;

可以使用:

podman --help



podman 二级指令 --help(如 podman run --help)查询帮助。

# - 搜索镜像,如 openresty
podman search openresty
# - 安装镜像
podman pull openresty/openresty
podman pull openresty/openresty:alpine # 指定镜像TAG
podman pull openresty/openresty:latest # 指定镜像TAG
# - 运行镜像
podman run -idt -p 12123:80 -v \
/opt/openresty/nginx/conf:/usr/local/openresty/nginx/conf:Z
--name openresty --privileged=true openresty/openresty:alpine
# -i 允许对容器进行交互
# -d 后台运行 不会进入容器
# -t 在新容器内指定一个伪终端或终端
# -p 建立端口映射,主机(宿主)端口:容器端口
# -v 文件存储,左侧为映射到本地:右侧为容器内文件夹,防止镜像过大,迁移困难
# --privileged 给容器权限
# --name 给启动的容器命名
# --net=host,这种是允许虚拟机和宿主机使用同一套网络,不能和-p同时使用,否则会报错:Port mappings have been discarded as one of the Host, Container, Pod, and None network modes are in use # 查看运行的容器
podman ps -a
podman ps -f + 过滤条件扩展
#podman ps -f ancestor= before= exited= health= id= label= name= network= since= status= until= volume= # 进入容器(后面可以根据实际选用sh或bash)
podman exec -it 容器id sh
podman exec -it 容器name sh # 停止容器
podman stop 容器id
podman stop 容器name # 删除容器
podman rm 容器id
podman rm 容器name # 删除镜像
podman rmi 镜像名称

根据关键词进入容器:

enter_container.sh

#!/bin/bash
container_keyword=$1 function Usage()
{
echo -e "Usage: $0 <container_keyword>"
exit 0
} if [[ $container_keyword == "" ]];then
Usage
fi # find container id
container_id=`podman ps -a|grep $container_keyword|awk -F' ' '{print $1}'`
if [[ $container_id == "" ]];then
echo "not find container by keyword $container_keyword"
exit 0
fi # enter container
podman exec -it $container_id bash
if [[ $? != 0 ]];then
podman exec -it $container_id sh
fi

停止所有容器:

stop_all.sh

#!/bin/bash
podman stop $(podman ps -a|grep -v CONTAINER|awk -F ' ' '{print $1}'|xargs)

删除所有已经停止的容器:

rm_all.sh

#!/bin/bash
podman rm $(podman ps -a|grep Exited |awk -F ' ' '{print $1}'|xargs)

参考

[1]. podman的配置以及命令详解;

[2]. Ubuntu安装podman;

[3]. 【Docker】docker介绍及podman使用命令;

[4]. docker run 命令详解(新手入门必备)

ubuntu podman相关的更多相关文章

  1. Ubuntu用户相关基本命令

    Linux是一个用户权限管理得很严格的系统,Ubuntu作为最受欢迎的桌面发行版,提供了简单易用的图形界面工具来管理用户,但是命令行工具往往更强大,用得熟练的话效率会更高.用户管理命令常用的有如下几个 ...

  2. ubuntu ufw相关命令

    引自:http://www.cnblogs.com/jiangyao/archive/2010/05/19/1738909.html 就这句话就够了,下面的可以不看 sudo  ufw enable| ...

  3. Ubuntu操作系统相关

    1.安装 三种网络类型 修改密码 重启unbuntu系统,出现starting启动界面后,长按shift键. 出现如下引导界面: (注意:这里保持默认的选项就行,即白色横条选择在*Ubuntu上,不要 ...

  4. (整理)ubuntu 的 相关知识(来自 鸟哥的私房菜)

    1. Linux 文件权限概念 $ ls 察看文件的指令 $ ls -al 出所有的文件详细的权限与属性 (包含隐藏档,就是文件名第一个字符为『 . 』的文件) 在你第一次以root身份登入Linux ...

  5. ubuntu PHP相关操作

    php开启重写模块 vim /etc/apache2/apache2.conf 写入<Directory /阿帕奇的项目目录> AllowOverride All </Directo ...

  6. seafile ubuntu 安装相关

    1,各种原因,需要安装 seafile,好,开始安装. 2,参考 https://github.com/haiwen/seafile-server-installer-cn 1,Ubuntu 16.0 ...

  7. linux和ubuntu防火墙相关命令

    1.永久有效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2.即刻生效 开启: service iptables start 关闭: se ...

  8. Ubuntu 系统信息相关命令

    系统信息相关命令 本节内容主要是为了方便通过远程终端维护服务器时,查看服务器上当前 系统日期和时间 / 磁盘空间占用情况 / 程序执行情况 本小结学习的终端命令基本都是查询命令,通过这些命令对系统资源 ...

  9. ubuntu安装相关

    安装系统参考:http://xinzhi.wenda.so.com/a/1523530837610141 首先进行更新源 sudo apt-get update 安装codeblocks sudo a ...

  10. 树莓派中安装ubuntu及相关设置

    一.下载并烧录系统 首先准备好我们要烧录的ubuntu_meta系统,可以在树莓派官网中下载https://www.raspberrypi.org/downloads/ 这里我们选择 Raspberr ...

随机推荐

  1. windows10安装ruby

    下载ruby 下载地址: ruby各版本下载地址 https://rubyinstaller.org/downloads/ 2.3.3版本 https://www.cr173.com/soft/142 ...

  2. ansible(2)--ansible的安装与配置文件管理

    目录 1 ansible的安装 1.1 yum安装 1.2 pip安装 2 ansible相关文件 2.1 ansible配置文件 2.2 ansible配置文件的优先级 2.3 ansible的主机 ...

  3. Spring环境获取Spring的Bean

    一.测试数据准备 /* Navicat Premium Data Transfer Source Server : swp-mysql Source Server Type : MySQL Sourc ...

  4. Java简单实现MQ架构和思路01

    实现一个 MQ(消息队列)架构可以涉及到很多方面,包括消息的生产和消费.消息的存储和传输.消息的格式和协议等等.下面是一个简单的 MQ 架构的实现示例,仅供参考: 定义消息格式和协议:我们可以定义一个 ...

  5. 谈谈 Spring 的过滤器和拦截器

    前言 我们在进行 Web 应用开发时,时常需要对请求进行拦截或处理,故 Spring 为我们提供了过滤器和拦截器来应对这种情况.那么两者之间有什么不同呢?本文将详细讲解两者的区别和对应的使用场景. ( ...

  6. Anagrams(字谜)

    描述 Most crossword puzzle(猜字谜) fans are used to anagrams(字谜)--groups of words with the same letters i ...

  7. 【昇腾开发全流程】AscendCL开发板模型推理

    前言 学会如何安装配置华为云ModelArts.开发板Atlas 200I DK A2. 并打通一个Ascend910训练到Ascend310推理的全流程思路. 在本篇章,我们继续进入推理阶段! 推理 ...

  8. Mp4V2与ffmpeg静态库符号冲突问题解决

    一.为什么静态符号会冲突 无论macho二进制类型,还是Windows上的PE格式,还是Linux上的ELF格式,里面都是按照特定格式存放的一个程序的代码和数据 比如Linux下的可执行文件格式,大致 ...

  9. containerd 源码分析:创建 container(一)

    0. 前言 Kubernetes:kubelet 源码分析之 pod 创建流程 介绍了 kubelet 创建 pod 的流程,containerd 源码分析:kubelet 和 containerd ...

  10. 使用 Hugging Face 推理终端搭建强大的“语音识别 + 说话人分割 + 投机解码”工作流

    Whisper 是当前最先进的开源语音识别模型之一,毫无疑问,也是应用最广泛的模型.如果你想部署 Whisper 模型,Hugging Face 推理终端 能够让你开箱即用地轻松部署任何 Whispe ...