Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About

第 2 章 Podman


2.1. 安装 Podman
2.1.1. RockyLinux 安装 Podman
2.1.2. Almalinux 9.0
2.1.3. MacOS 安装 Podman
2.1.4. 初始化 Podman
2.1.5. 让 Podman 支持 Docker Compose
2.1.6. 配置 Podman
2.2. podman 管理
2.2.1. 虚拟机管理
2.2.2. 镜像管理
2.2.3. Registry
2.3. 按例
2.3.1. podman run 用法
2.3.2. mysql
2.3.3. 制作镜像

2.1. 安装 Podman

2.1.1. RockyLinux 安装 Podman

某些 Redhat 家族的 Linux 是自带 Podman,例如 Almalinux 9.0,RockyLinux没有自带 podman 需要自己安装,是方法执行下面的命令

[root@netkiller ~]# dnf install -y podman

2.1.2. Almalinux 9.0

Almalinux 9.0 自带 podman

systemctl enable podman		

2.1.3. MacOS 安装 Podman

MacOS 安装方法

brew install podman

2.1.4. 初始化 Podman

初始化,启动 Podman

podman machine init
podman machine start


neo@MacBook-Pro-M2 ~ % podman machine init
Downloading VM image: fedora-coreos-37.20221127.2.0-qemu.aarch64.qcow2.xz: done  
Extracting compressed file Image resized.
Machine init complete
To start your machine run:

    podman machine start

neo@MacBook-Pro-M2 ~ % podman machine start          
Starting machine "podman-machine-default"
Waiting for VM ...
Mounting volume... /Users/neo:/Users/neo

This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command: 

    podman machine set --rootful

API forwarding listening on: /Users/neo/.local/share/containers/podman/machine/podman-machine-default/podman.sock

The system helper service is not installed; the default Docker API socket
address can't be used by podman. If you would like to install it run the
following commands:

    sudo /opt/homebrew/Cellar/podman/4.3.1/bin/podman-mac-helper install
    podman machine stop; podman machine start

You can still connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:

    export DOCKER_HOST='unix:///Users/neo/.local/share/containers/podman/machine/podman-machine-default/podman.sock'

Machine "podman-machine-default" started successfully

2.1.5. 让 Podman 支持 Docker Compose

启用 socket

systemctl enable podman.socket
systemctl start podman.socket
systemctl status podman.socket

验证 sock 是否正常工作

[root@localhost ~]# curl -H "Content-Type: application/json" --unix-socket /run/podman/podman.sock http://localhost/_ping

此时可以使用 docker compose

[root@localhost ~]# ln -s /run/podman/podman.sock /var/run/docker.sock		

2.1.6. 配置 Podman



$ podman pull maven
$ podman run -v ~/.m2:/root/.m2 \
-v /root/bottleneck:/root/bottleneck \
-w /root/bottleneck \
maven:latest \
mvn package