podman安装portainer并远程连接其他podman
安装portainer
1.启用套接字
systemctl enable --now podman.socket
2 创建容器卷 podman volume create portainer_data
数据文件路径在/var/lib/containers/storage/volumes/portainer_data
3.部署portainer
podman run -d -p 9443:9443 \
-v /run/podman/podman.sock:/var/run/docker.sock:Z \
-v portainer_data:/data \
--restart=always \
--name portainer \
portainer/portainer-ce
podman-compose部署方式
version: "3"
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
privileged: true
ports:
- "9443:9443"
volumes:
- /app/portainer/data:/data
- /run/podman/podman.sock:/var/run/docker.sock:Z
访问地址:https://ip:9443
远程连接podman
点击add environment
选择docker standalone
用第一种方式agent
被控端需要安装agent
mkdir -p /var/lib/containers/storage/volumes
podman run -d -p 9001:9001 \
--name portainer_agent \
--restart=always \
-v /run/podman/podman.sock:/var/run/docker.sock:Z \
-v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
-v /:/host \
portainer/agent
podman-compose方式
version: "3.0"
services:
portainer-agent:
container_name: portainer-agent
image: portainer/agent
restart: always
privileged: true
ports:
- "9001:9001"
volumes:
- /run/podman/podman.sock:/var/run/docker.sock:Z
- /var/lib/containers/storage/volumes:/var/lib/docker/volumes
- /:/host
添加完成
如果出现停止删除容器报错:it could not be stopped: given PID did not die within timeout
执行rm –rf /var/lib/containers/storage/volumes,然后重启系统后执行 Podman stop,这时候可以正常停止删除 如果不想重启电脑 执行ps aux | grep portainer_agent
Kill -9 913
podman rm –f portainer_agent
在执行的时候需要添加参数,使用特权模式,在后续stop容器后不会出现上面的问题 podman run --privileged
如果关闭sellinux也不会出现上述情况
Ubuntu没有sellinux,而是用的AppArmor
禁用apparmor
systemctl disable apparmor
systemctl stop apparmor
查看 apparmor 的开启和保护情况
apparmor_status
添加镜像仓库
拉取镜像
License:
CC BY 4.0