ubuntu podman相关
前言
记录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相关的更多相关文章
- Ubuntu用户相关基本命令
Linux是一个用户权限管理得很严格的系统,Ubuntu作为最受欢迎的桌面发行版,提供了简单易用的图形界面工具来管理用户,但是命令行工具往往更强大,用得熟练的话效率会更高.用户管理命令常用的有如下几个 ...
- ubuntu ufw相关命令
引自:http://www.cnblogs.com/jiangyao/archive/2010/05/19/1738909.html 就这句话就够了,下面的可以不看 sudo ufw enable| ...
- Ubuntu操作系统相关
1.安装 三种网络类型 修改密码 重启unbuntu系统,出现starting启动界面后,长按shift键. 出现如下引导界面: (注意:这里保持默认的选项就行,即白色横条选择在*Ubuntu上,不要 ...
- (整理)ubuntu 的 相关知识(来自 鸟哥的私房菜)
1. Linux 文件权限概念 $ ls 察看文件的指令 $ ls -al 出所有的文件详细的权限与属性 (包含隐藏档,就是文件名第一个字符为『 . 』的文件) 在你第一次以root身份登入Linux ...
- ubuntu PHP相关操作
php开启重写模块 vim /etc/apache2/apache2.conf 写入<Directory /阿帕奇的项目目录> AllowOverride All </Directo ...
- seafile ubuntu 安装相关
1,各种原因,需要安装 seafile,好,开始安装. 2,参考 https://github.com/haiwen/seafile-server-installer-cn 1,Ubuntu 16.0 ...
- linux和ubuntu防火墙相关命令
1.永久有效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2.即刻生效 开启: service iptables start 关闭: se ...
- Ubuntu 系统信息相关命令
系统信息相关命令 本节内容主要是为了方便通过远程终端维护服务器时,查看服务器上当前 系统日期和时间 / 磁盘空间占用情况 / 程序执行情况 本小结学习的终端命令基本都是查询命令,通过这些命令对系统资源 ...
- ubuntu安装相关
安装系统参考:http://xinzhi.wenda.so.com/a/1523530837610141 首先进行更新源 sudo apt-get update 安装codeblocks sudo a ...
- 树莓派中安装ubuntu及相关设置
一.下载并烧录系统 首先准备好我们要烧录的ubuntu_meta系统,可以在树莓派官网中下载https://www.raspberrypi.org/downloads/ 这里我们选择 Raspberr ...
随机推荐
- MySQL:根据指定日期加365天,当前时间距离明年的指定的日期还有多少天-SQL
一.数据准备 /* Navicat Premium Data Transfer Source Server : songweipeng Source Server Type : MySQL Sourc ...
- vueJs开发音乐播放器第二篇(点击歌单跳出详情页)
继上一篇开发音乐播放器歌单列表页 (1.使用router定义跳转链接,2. 使用axios得到音乐第三方数据,并渲染到页面上,3.组件之间传值(props)) 1.接下来使用了vue-router路由 ...
- C语言:学生成绩排名----冒泡排序
题目: /* 输入10个学生成绩. 计算总分以及平均分数. 求出高于等于平均分的人数. 再按降序(由大到小)排序成绩并输出 */ 用到的冒泡算法代码模板: / ...
- IPv6 — 实践
目录 文章目录 目录 前文列表 常用命令 开启/关闭 IPv6 支持 在 CentOS7 上配置 IPv6 地址 自动获取链路本地地址 配置静态全球唯一地址 配置临时 IPv6 地址 添加 IPv6 ...
- 程序编译流程与 GCC 编译器
目录 文章目录 目录 GUN 计划 GCC 编译器 Clang 和 LLVM GCC 的常用指令选项 GCC 所遵循的部分约定规则 GCC 的编译流程 GCC 的编译流程示例 编译多个文件 GUN 计 ...
- 移动通信网络中的 3A 实现
目录 文章目录 目录 3A RADIUS Diameter 基本概念 基本协议 应用协议 freeDiameter 3A AAA,即认证(Authentication).授权(Authorizatio ...
- 腾讯云服务器sdk
参考:https://cloud.tencent.com/document/product/494/7244 pip install -i https://mirrors.tencent.com/py ...
- systemctl管理自定义服务模版
一 日常工作中,有许多需要使用systemctl进行管理服务的时候 [Unit] Description=radius Release [Service] ExecStart=/etc/init.d ...
- 【U8】 生产订单下bom 提示 “遇到以0做除数错误”错误
一个虚拟件子件的子件为无换算率存货,bom中对应的换算率.辅助基本用量为0,修改为null后正常. 对应 bom_opcomponent表的 ChangeRate 换算率 AuxBaseQtyN 辅助 ...
- Servlet转发与重定向的资源路径问题解析
一. 问题引入 转发和重定向可以说是Servlet中最重要的知识点也不为过,因为它决定着整个向Servlet体系中,执行流程的问题. 转发: request.getRequestDispat ...