Optimize content and fix issues

This commit is contained in:
baohua
2026-03-03 19:30:03 -08:00
parent be09a95d0d
commit a096947382
18 changed files with 239 additions and 506 deletions

View File

@@ -2,7 +2,7 @@
[`podman`](https://github.com/containers/podman) 是一个无守护进程、与 Docker 命令高度兼容的下一代 Linux 容器工具。它由 Red Hat 开发,旨在提供一个更安全的容器运行环境。
## 17.3 Podman vs Docker
### 17.3.1 Podman vs Docker
Podman Docker 在设计理念上存在显著差异主要体现在架构和权限模型上
@@ -13,17 +13,17 @@ Podman 和 Docker 在设计理念上存在显著差异,主要体现在架构
| **生态** | 完整的生态系统 (Compose, Swarm) | 专注单机容器配合 Kubernetes 使用 |
| **镜像构建** | `docker build` | `podman build` `buildah` |
## 17.3 安装
### 17.3.2 安装
Podman 支持多种操作系统安装过程也相对简单
### 17.3.1 CentOS / RHEL
#### CentOS / RHEL
```bash
$ sudo yum -y install podman
```
### 17.3.2 macOS
#### macOS
macOS 上需要安装 Podman Desktop 或通过 Homebrew 安装
@@ -33,11 +33,11 @@ $ podman machine init
$ podman machine start
```
## 17.3 使用
### 17.3.3 基本使用
`podman` 的命令行几乎与 `docker` 完全兼容大多数情况下你只需将 `docker` 替换为 `podman` 即可
### 17.3.1 运行容器
#### 运行容器
```bash
## $ docker run -d -p 80:80 nginx:alpine
@@ -45,21 +45,21 @@ $ podman machine start
$ podman run -d -p 80:80 nginx:alpine
```
### 17.3.2 列出容器
#### 列出容器
```bash
$ podman ps
```
### 17.3.3 构建镜像
#### 构建镜像
```bash
$ podman build -t myimage .
```
## 17.3 Pods 的概念
### 17.3.4 Pods 的概念
Docker 不同Podman 支持 Pod 的概念 (类似于 Kubernetes Pod)允许你在同一个网络命名空间中运行多个容器
Docker 不同Podman 支持Pod的概念 (类似于 Kubernetes Pod)允许你在同一个网络命名空间中运行多个容器
```bash
## 创建一个 Pod
@@ -71,7 +71,7 @@ $ podman pod create --name mypod -p 8080:80
$ podman run -d --pod mypod --name webbing nginx
```
## 17.3 迁移到 Podman
### 17.3.5 迁移到 Podman
如果你习惯使用 `docker` 命令可以简单地设置别名
@@ -79,8 +79,6 @@ $ podman run -d --pod mypod --name webbing nginx
$ alias docker=podman
```
### 17.3.1 进阶用法
#### Systemd 集成
Podman 可以生成 systemd 单元文件让容器像普通系统服务一样管理
@@ -107,8 +105,3 @@ $ systemctl --user enable --now container-myweb.service
$ pip3 install podman-compose
$ podman-compose up -d
```
### 17.3.2 参考
* [Podman 官方网站](https://podman.io/)
* [Podman GitHub 仓库](https://github.com/containers/podman)