How to add Podman as an Agent in Portainer

A Possible approach to adding Podman as an environment in Portainer is two ways. The first is to use the Portainer Agent. The other way is to call it through the remote API.

Try1: Portainer Agent

Start Portainer Agent

  • rootless
podman run -d \
    -p 9001:9001 \
    --name portainer_agent \
    --restart=always \
    --privileged \
    -v /run/podman/podman.sock:/var/run/docker.sock:Z \
    -v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
    -v /:/host \
    portainer/agent:2.19.5
  • rootful
podman run -d -p 9001:9001 \
    --name portainer_agent \
    --security-opt label=disable \
    --restart=always \
    -v /run/user/$(id -u)/podman/podman.sock:/var/run/docker.sock:Z \
    -v ${HOME}/.local/share/containers/storage/volumes:/var/lib/docker/volumes \
    portainer/agent:2.19.5

I tried and it didn't work. My Environment

  • Portainer CE 2.19.5
  • Portainer Agent 2.19.5
  • RedHat 8.9

I found, it cannot read an agent container IP address when starting. The full error is below.

[invsbch@dev-test ~]$ podman logs 448056c677e6
2024/05/03 09:45AM INF ./main.go:86 > agent running on Docker platform |
2024/05/03 09:45AM DBG ./main.go:96 > member_tags="&{AgentPort:9001 EdgeKeySet:false NodeName:dev-test DockerConfiguration:{EngineStatus:1 Leader:false NodeRole:0} KubernetesConfiguration:{}}"
2024/05/03 09:45AM WRN ./main.go:112 > unable to retrieve agent container IP address, using host flag instead | error="unable to retrieve the address on which the agent can advertise. Check your network settings" host_flag=0.0.0.0
2024/05/03 09:45AM INF github.com/portainer/agent/edge/registry/server.go:101 > starting registry credential server |
2024/05/03 09:45AM INF github.com/portainer/agent/http/server.go:99 > starting Agent API server | api_version=2.19.5 server_addr=0.0.0.0 server_port=9001 use_tls=true
[invsbch@dev-test ~]$ 
[invsbch@dev-test ~]$ 
[invsbch@dev-test ~]$ podman stop 448
448

Try2: Podman Remote API

When the first method doesn't work, we try another method using the Podman Remote API. The steps are as follows:

  • The first step is to enable Podman remote API, you can follow the steps in my blog > How to Enable Remote API in Podman
  • Go to Portainer Dashboard > Environment > Add Environment > API
    - Enter Environment Name
    - Enter Environment EndPoint (Podman Remote API)
  • It works!
  • Test
    - List image: podman images via api
    - List Container: podman ps via api

Note: When I tested on Portainer > Podman, Some feature may not working properly,
but almost view / container management (Ex. Start / Stop / Restart / Remove) work correctly.

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts sent to your email.