Fix and update

This commit is contained in:
baohua
2026-02-09 11:34:35 -08:00
parent e669ee0fe8
commit 63377d0431
136 changed files with 2146 additions and 262 deletions

View File

@@ -1,8 +1,10 @@
## podman
# podman
[`podman`](https://github.com/containers/podman) 是一个无守护进程、与 Docker 命令高度兼容的下一代 Linux 容器工具。它由 Red Hat 开发,旨在提供一个更安全的容器运行环境。
### Podman vs Docker
## Podman vs Docker
Podman Docker 在设计理念上存在显著差异主要体现在架构和权限模型上
| 特性 | Docker | Podman |
| :--- | :--- | :--- |
@@ -11,15 +13,19 @@
| **生态** | 完整的生态系统 (Compose, Swarm) | 专注单机容器配合 Kubernetes 使用 |
| **镜像构建** | `docker build` | `podman build` `buildah` |
### 安装
## 安装
#### CentOS / RHEL
Podman 支持多种操作系统安装过程也相对简单
### CentOS / RHEL
运行以下命令
```bash
$ sudo yum -y install podman
```
#### macOS
### macOS
macOS 上需要安装 Podman Desktop 或通过 Homebrew 安装
@@ -29,11 +35,13 @@ $ podman machine init
$ podman machine start
```
### 使用
## 使用
`podman` 的命令行几乎与 `docker` 完全兼容大多数情况下你只需将 `docker` 替换为 `podman` 即可
#### 运行容器
### 运行容器
运行以下命令
```bash
## $ docker run -d -p 80:80 nginx:alpine
@@ -41,31 +49,37 @@ $ podman machine start
$ podman run -d -p 80:80 nginx:alpine
```
#### 列出容器
### 列出容器
运行以下命令
```bash
$ podman ps
```
#### 构建镜像
### 构建镜像
运行以下命令
```bash
$ podman build -t myimage .
```
### Pods 的概念
## Pods 的概念
Docker 不同Podman 支持 "Pod" 的概念类似于 Kubernetes Pod允许你在同一个网络命名空间中运行多个容器
```bash
## 创建一个 Pod
$ podman pod create --name mypod -p 8080:80
## 在 Pod 中运行容器
$ podman run -d --pod mypod --name webbing nginx
```
### 迁移到 Podman
## 迁移到 Podman
如果你习惯使用 `docker` 命令可以简单地设置别名
@@ -80,12 +94,15 @@ Podman 可以生成 systemd 单元文件,让容器像普通系统服务一样
```bash
## 创建容器
$ podman run -d --name myweb -p 8080:80 nginx
## 生成 systemd 文件
$ podman generate systemd --name myweb --files --new
## 启用并启动服务
$ systemctl --user enable --now container-myweb.service
```