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 ...
随机推荐
- Go:基于 MongoDB 构建 REST API — Fiber 版
本文主要在于带着大家完成一个基本的 CRUD 工作,让大家熟悉 Fiber + MongoDB 构建 RESTful API,熟悉工作流程.同时了解相关库的使用. 本文的完整代码见:https://g ...
- WEB服务与NGINX(8)-NGINX的长连接功能
1. 长连接配置 keepalive_timeout; 定义客户端保持连接超时时长,0表示禁止长连接,默认为65s,建议使用15s即可. 在ngx_http_upstream_module中也有此项设 ...
- fastposter v2.11.0 天花板级的海报生成器
fastposter v2.11.0 天花板级的海报生成器 fastposter海报生成器是一款快速开发海报的工具.只需上传一张背景图,在对应的位置放上组件(文字.图片.二维.头像)即可生成海报. 点 ...
- 启动vite和electron项目配置多个主进程
推荐 concurrently 点击查看代码 "dev": "concurrently \"nodemon --exec electron . \" ...
- 基于 three.js 加载器分别加载模型
点击查看代码 /** * 参数:模型文件路径,成功回调函数 * * 基于 three.js 加载器分别加载模型 * * 全部加载后通过回调函数传出打印 */ import { FBXLoader } ...
- 【漏洞通报】WEB VIDEO PLATFORM疑似存在未授权访问漏洞
漏洞描述 WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的开箱即用的网络视频平台,负责实现核心信令与设备管理后台部分,支持NAT穿透,支持海康.大华.宇视等品牌的IPC ...
- 推荐一款模拟浏览器自动化操作神器!Mechanize
大家好,我是狂师! 今天给大家推荐一款用于模拟浏览器行为以进行网页自动化操作Python库:Mechanize. 1.介绍 Mechanize是Python中的一个库,它被设计用来自动化网页浏览和数据 ...
- Biwen.Settings添加对IConfiguration&IOptions的集成支持
Biwen.Settings 是一个简易的配置项管理模块,主要的作用就是可以校验并持久化配置项,比如将自己的配置存储到数据库中,JSON文件中等 使用上也是很简单,只需要在服务中注入配置即可, 比如我 ...
- Supervisor 守护进程管理工具
引言 Supervisor 是基于 Python 编程语言开发的一套通用的进程管理程序,它是通过 fork/exec 的方式把需要管理的进程作为子进程来管理. 安装 pip3 安装 superviso ...
- Nginx 修饰符 Location 详解
概述 location 指令可以用在虚拟服务器 server 部分,并且意味着提供来自客户端的 URI 或者内部重定向访问. location 的定义如下: location [modifier] u ...