Podman 介绍

发布时间: 更新时间: 总字数:1002 阅读时间:2m 作者:IP:上海 网址

Podman(Pod Manager tool) 是一个开源的容器项目,它可以管理和运行任何符合 OCI(Open Container Initiative) 规范的容器和镜像

什么是Podman

  • 可以跨平台使用,支持大多数 Linux、Mac、Windows
  • Podman 运行不需要守护进程,并可以在非 root 权限下运行
  • Podman 与 Docker 功能相似,并兼容 Docker Cli (约 85%+ 的命令是相似的),可以管理 Docker 镜像,也可以配置 alias docker=podman 使用 docker 命令

安装 Remote Client

  • Fedora,Centos
sudo yum -y install podman
  • MacOS
brew install podman
brew link podman

Help

podman--help

配置

镜像

  • $HOME/.config/containers/registries.conf
unqualified-search-registries = ['docker.io', 'k8s.gcr.io', 'quay.io']

[[registry]]
prefix = "docker.io"
location = "hub-mirror.c.163.com"

[[registry.mirror]]
prefix = "docker.io"
location = "dockerhub.azk8s.cn"

[[registry]]
prefix = "k8s.gcr.io"
location = "gcr.azk8s.cn/google_containers"

[[registry]]
prefix = "quay.io"
location = "quay.azk8s.cn"

启动 Podman-managed VM

Mac 中需要在虚拟机中启动 podman

podman-machine--help

启动 Podman-managed VM

# 下载 fedora-coreos-xxx-qemu.x86_64.qcow2.xz,并启动
podman machine init
podman machine start

# info
podman info
$ podman machine list
NAME                     VM TYPE     CREATED         LAST UP
podman-machine-default*  qemu        10 minutes ago  12 seconds ago
$ podman machine stop
$ podman machine start podman-machine-default
Waiting for VM ...
$ podman machine ssh podman-machine-default

使用

镜像

  • 拉取 docker 镜像
$ podman pull alpine
$ podman pull
$ podman pull centos:7
Resolved "centos" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull quay.io/centos/centos:7...
Getting image source signatures
Copying blob sha256:2d473b07cdd5f0912cd6f1a703352c82b512407db6b05b43f2553732b55df3bc
Copying blob sha256:2d473b07cdd5f0912cd6f1a703352c82b512407db6b05b43f2553732b55df3bc
Copying config sha256:8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf
Writing manifest to image destination
Storing signatures
8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf
podman run -it -d --name git \
-v /Users/xiexianbin/work/code/github.com/KiwiNetworkOrg:/data \
centos:7

由于 Podman 的命令和 Docker 很类似,参考:Docker Client

FAQ

获取镜像异常

  • 错误日志
$ podman pull centos:7
{
Error: failed to parse "X-Registry-Auth" header for /v3.2.3/libpod/images/pull?alltags=false&arch=&authfile=&os=&password=&policy=always&quiet=false&reference=centos%3A7&username=&variant=: error storing credentials in temporary auth file (server: "https://index.docker.io/v1/", user: ""): key https://index.docker.io/v1/ contains http[s]:// prefix
  • 解决方法

删除 ~/.docker/config.jsonauths 中的内容为:"auths": {}

本文总阅读量 次 本站总访问量 次 本站总访客数