$ ls ~yifei/notes/

Podman 对比 Docker 使用笔记

Posted on:

Last modified:

podman 基本上和 docker 命令兼容

  • 没有 daemon,默认不使用 root
  • 可以导出 k8s 部署配置
  • 可以一键停止删除所有容器,stop -a, rm -a, rmi -a 等
  • 增加了 -l、--latest 选项,直接操作上一个 container,而不需要找到 id 然后再操作。

Podman 最贴心的的部分在于命令行更加人性化。

比如说:

podman stop -l
podman rm -a

podman-compose

pip3 install podman-compose

podman play

podman 有个 bug,默认不会打开 cache,需要使用 --layers 手动打开.

podman build --layers .

Use podman on macOS

虽然在 mac 上,可以用 podman 自己带的虚拟机,但是这个虚拟机是 CentOS 的系统,不太习惯, 所以还是用 multipass 起一个 ubuntu 的机器来用吧。

multipass launch -c 2 -m 8G -d 64G -n podman
multipass mount $HOME podman:/home/ubuntu/host
multipass shell podman

Install latest podman on Ubuntu

#!/bin/sh

ubuntu_version='22.04'
key_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}/Release.key"
sources_url="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_${ubuntu_version}"

echo "deb $sources_url/ /" | tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list
curl -fsSL $key_url | gpg --dearmor | tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null
apt update
apt install podman

build amd64 image on ARM64/M1

apt-get install -y qemu-user-static
reboot
podman build --platform linux/amd64

参考

  1. https://developers.redhat.com/blog/2019/02/21/podman-and-buildah-for-docker-users/
  2. https://cloud.redhat.com/blog/crictl-vs-podman
  3. https://podman.io/getting-started/
  4. https://askubuntu.com/questions/1414446/whats-the-recommended-way-of-installing-podman-4-in-ubuntu-22-04
  5. https://dev.to/tkral/podman-build-amd64-images-on-m1-294g
WeChat Qr Code

© 2016-2022 Yifei Kong. Powered by ynotes

All contents are under the CC-BY-NC-SA license, if not otherwise specified.

Opinions expressed here are solely my own and do not express the views or opinions of my employer.

友情链接: MySQL 教程站