惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MongoDB | Blog
MongoDB | Blog
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
罗磊的独立博客
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
SegmentFault 最新的问题
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
博客园 - 司徒正美
博客园 - 叶小钗
T
Tailwind CSS Blog
博客园 - Franky
V
V2EX
有赞技术团队
有赞技术团队
美团技术团队
雷峰网
雷峰网
爱范儿
爱范儿
Jina AI
Jina AI
D
DataBreaches.Net
H
Help Net Security
酷 壳 – CoolShell
酷 壳 – CoolShell

Jiajun的技术笔记

你好,2026! TiDB 源码阅读(六):TiDB Coprocessor 源码解析 性能优化的核心思想 TiDB 源码阅读(五):索引 TiDB 源码阅读(四):AST、逻辑计划、物理计划 CockroachDB Serverless Architecture podman 无故退出 Cursor Control-L (CTRL-L) Keyboard Shortcuts in Terminal Using xmonad with xfce4 A RC script for freebsd frpc 自己动手写一个k8s controller AI 会取代你的(编程)岗位吗? 自建DERP服务器提升Tailscale连接速度(使用Nginx转发) 自动升级Docker容器 再读《程序员修炼之道-从小工到专家》 让浏览器下载文件 再读《软件随想录》/《黑客与画家》/《软技能》 HTTP 压力测试中的 Coordinated Omission 2的补码 编程语言中的 context 是什么? flutter macOS 构建出错 Flatpak 使用小记 Golang CAS 操作是怎么实现的 PostgreSQL 当MQ来使用 Clash 结合 工作VPN 的网络设计 使用 PostgreSQL 搭建 JuiceFS PostgreSQL 配置优化和日志分析 有GitHub Copilot?那就可以搭建你的ChatGPT4服务 窗口函数的使用(以PG为例) 读《为什么学生不喜欢上学》
Replace docker with podman
Jiajun Huang · 2025-03-21 · via Jiajun的技术笔记

Most of the commands in podman is same as docker, it is easy to replace docker with podman. The difference is:

  1. When you running container by using docker, as docker is a client-server architecture, docker use a daemon to run container, podman run container directly;

  2. If you don’t specify the user and group, the user and group you running podman command will be used;

  3. A configuration file is required to run podman, save it to /etc/containers/registries.conf:

    unqualified-search-registries = ['docker.io']
    
    [[registry]]
    # In Nov. 2020, Docker rate-limits image pulling.  To avoid hitting these
    # limits while testing, always use the google mirror for qualified and
    # unqualified `docker.io` images.
    # Ref: https://cloud.google.com/container-registry/docs/pulling-cached-images
    prefix="docker.io"
    location="mirror.gcr.io"
    
    # 2020-10-27 a number of images are not present in gcr.io, and podman
    # barfs spectacularly when trying to fetch them. We've hand-copied
    # those to quay, using skopeo copy --all ...
    [[registry]]
    prefix="docker.io/library"
    location="mirror.gcr.io"
    

Nearly all the containers works fine in my homelab, except 2 cases:

Create a pod in podman when you’re using link in docker

I have a container with a link in docker:

#!/bin/bash
 
docker rm -f aria2-server
docker rm -f aria2-webui
 
docker pull p3terx/aria2-pro
docker pull p3terx/ariang
 
docker run -d \
    --name aria2-server \
    --restart unless-stopped \
    --log-opt max-size=1m \
    -e PUID=$UID \
    -e PGID=$GID \
    -e UMASK_SET=022 \
    -e RPC_SECRET="<YOUR_SECRET>" \
    -e RPC_PORT=6800 \
    -p 6800:6800 \
    -e LISTEN_PORT=6888 \
    -v /path/to/config:/config \
    -v /path/to/downloads:/downloads \
    p3terx/aria2-pro
 
 
docker run -d \
    --name aria2-webui \
    --log-opt max-size=1m \
    --restart unless-stopped \
    --link aria2-server \
    -p 6880:6880 \
    p3terx/ariang

when you replace docker with podman, it will fail:

Error: unknown flag: --link
See 'podman run --help'

It is because podman doesn’t support the --link option. The workaround is create a pod first:

#!/bin/bash

podman rm -f aria2-server
podman rm -f aria2-webui

podman pull p3terx/aria2-pro
podman pull p3terx/ariang

podman pod create --name aria2-pod --publish 6880:6880 --publish 6888:6888 --publish 6800:6800/udp

podman run -d \
    --name aria2-server \
    --pod aria2-pod \
    --restart unless-stopped \
    --log-opt max-size=1m \
    -e PUID=$UID \
    -e PGID=$GID \
    -e UMASK_SET=022 \
    -e RPC_SECRET="<YOUR_SECRET>" \
    -e RPC_PORT=6800 \
    -e LISTEN_PORT=6888 \
    -v /data/apps/aria2/config:/config \
    -v /data/hdd/share/media/downloads:/downloads \
    p3terx/aria2-pro


podman run -d \
    --name aria2-webui \
    --pod aria2-pod \
    --log-opt max-size=1m \
    --restart unless-stopped \
    p3terx/ariang

Run podman with woodpecker

When I run podman with woodpecker, it will fail in woodpecker-agent:

{"level":"info","time":"2025-03-20T04:07:23Z","message":"log level: info"}
{"level":"info","time":"2025-03-20T04:07:23Z","message":"no agent config found at '/etc/woodpecker/agent.conf', start with defaults"}
{"level":"error","engine":"docker","time":"2025-03-20T04:07:23Z","message":"selected backend engine is unavailable"}
{"level":"info","time":"2025-03-20T04:07:23Z","message":"shutdown of whole agent"}
{"level":"fatal","error":"selected backend engine docker is unavailable","time":"2025-03-20T04:07:23Z","message":"error running agent"}
{"level":"info","time":"2025-03-20T04:07:24Z","message":"log level: info"}
{"level":"info","time":"2025-03-20T04:07:24Z","message":"no agent config found at '/etc/woodpecker/agent.conf', start with defaults"}
{"level":"error","engine":"docker","time":"2025-03-20T04:07:24Z","message":"selected backend engine is unavailable"}
{"level":"info","time":"2025-03-20T04:07:24Z","message":"shutdown of whole agent"}
{"level":"fatal","error":"selected backend engine docker is unavailable","time":"2025-03-20T04:07:24Z","message":"error running agent"}

podman woodpecker agent

It is because woodpecker doesn’t support podman officially, it needs some hack:

podman run -d \
  --name woodpecker-agent \
  --pod woodpecker-pod \
  --restart always \
  --security-opt label=disable \
  --privileged \
  --pid=host \
  -v /run/user/1000/podman/podman.sock:/run/podman/podman.sock:z \
  -e DOCKER_HOST="unix:///run/podman/podman.sock" \
  -e WOODPECKER_BACKEND="docker" \
  -e WOODPECKER_SERVER=woodpecker-server:8010 \
  -e WOODPECKER_AGENT_SECRET=$WOODPECKER_AGENT_SECRET \
  -e WOODPECKER_MAX_WORKFLOWS=4 \
  woodpeckerci/woodpecker-agent:v3.4 agent

Conclusion

After replacing docker with podman, it is easy to run container in homelab, and I can manage all my containers in both command line and cockpit, which is very useful.


相关文章