Debian13安装Podman
1、安装podman
apt install -y podman
2、安装podman-compose
apt install -y podman-compose
3、配置镜像加速器
vim /etc/containers/registries.conf
写入配置
unqualified-search-registries = ["docker.io"]
[[registry]]
prefix = "docker.io"
location = "cccc.xxx.com"
insecure = true
4、运行了Podman跑容器的电脑重启后,无法正常启动容器,原因是因为Podman不使用Daemon守护进程,所以podman run命令没有–restart=always参数来重启容器。
解决方案一:
生成systemd文件
podman generate systemd --name nginx --files --new
生成不含 --new 参数的 systemd 服务文件,而非 podman run 新建容器
podman generate systemd --name nginx --files
将生成的文件移动到/etc/systemd/system
mv container-nginx.service /etc/systemd/system/
启动服务
systemctl daemon-reload
systemctl enable container-nginx.service
systemctl start container-nginx.service
解决方案二:(推荐)
新建:/etc/systemd/system/podman-bb.service
vim /etc/systemd/system/podman-bb.service
写入以下
[Unit]
Description=Podman Compose Stack
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/data
ExecStart=/usr/bin/podman-compose -f /data/docker-compose.yml up -d
ExecStop=/usr/bin/podman-compose -f /data/docker-compose.yml down
TimeoutStartSec=60
[Install]
WantedBy=multi-user.target
然后重载:
systemctl daemon-reload
systemctl restart podman-bb