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 ...
随机推荐
- HTML——基本标签
1.标题标签 <h1>标题1</h1> <h2>标题2</h2> <h3>标题3</h3> <h4>标题4</ ...
- Android 13 - Media框架(7)- NuPlayer::Source
关注公众号免费阅读全文,进入音视频开发技术分享群! Source 在播放器中起着拉流(Streaming)和解复用(demux)的作用,Source 设计的好坏直接影响到播放器的基础功能,我们这一节将 ...
- .net core 下 DES &MD5加密
項目中經常會用到加密解密,分享 DES & MD5加密,當然我們建議使用MD5. #region DES encrypt, decrypt public string EncryptDES(s ...
- kubernetes的三种探针startupprobe,ReadinessProbe,LivenessProbe记录
kubernetes的三种探针 startupprobe: k8s1.16版本后新加的探测方式,用于判断容器内应用程序是否已经启动,如果配置了startuprobe,就会先禁用其他的探测,直到它成功为 ...
- nonatomic 带来的线程安全问题
一.结论 一个对象对外暴露的读写属性,如果这个属性在多个线程中访问,一定会出现crash. 因此对外暴露的属性一定要考虑线程安全问题. 二.看下面的代码 下面的代码一定会crash,除非obj是ato ...
- Redis 常用的数据结构简介与实例测试【Redis 系列二】
〇.都有哪些数据结构? Redis 提供了较为丰富的数据类型,常见的有五种:String(字符串),Hash(哈希),List(列表),Set(集合).Zset(有序集合). 随着 Redis 版本的 ...
- Spark-submit常用任务命令参数和说明
Spark常用任务命令参数和说明 spark-submit \ --name task2018072711591669 \ --master yarn --deploy-mode client \ - ...
- ssh练习
根据要求完成部署 根据如下要求,完成部署过程 1.恢复7.8.9.31.41所有机器的快照 7 8 9 web服务 nginx 172.16.1.xx nfs-31 提供共享文件存储 ...
- 牛客网在线编程-语法篇-基础语法——C 语言解题集
前言 牛客网在线编程-语法篇-基础语法--C 语言解题集. 点击下方超链接跳转至对应编程题目,文章包含解析及源码. 01-基础语法 简单输出 BC1-Hello Nowcoder BC2-小飞机 基本 ...
- vite+vue3+ts+elementPlus前端框架搭建 [一]
记录下搭建vite + vue3 + ts + elementPlus项目的过程及遇到的问题. 建议使用pnpm安装依赖,npm切换到pnpm 链接地址:[https://www.pnpm.cn/in ...