Skip to content

Instantly share code, notes, and snippets.

@sshtmc
Last active July 1, 2023 18:08
Show Gist options
  • Save sshtmc/53ff4ddb612293f2f1dde45020b8f27f to your computer and use it in GitHub Desktop.
Save sshtmc/53ff4ddb612293f2f1dde45020b8f27f to your computer and use it in GitHub Desktop.

Portainer with Podman

config:
  cloud-init.user-data: |
    #cloud-config
    manage_etc_hosts: true
    timezone: UTC
    users:
      - default
    ssh_pwauth: false
    disable_root: true
    repo_upgrade: all
    package_upgrade: true
    packages:
      - vim
      - openssh-server
      - podman
    write_files:
      - path: /etc/containers/registries.conf
        content: |
          [registries.search]
          registries = ['docker.io']
        append: true
    runcmd:
      - [ usermod, -p, '*', sat ]
      - [ systemctl, enable, --now, podman.socket ]
      - [ podman, pull, portainer/portainer-ce ]
      - [ podman, run, -d, -p, 9443:9443, --name, portainer, --privileged, -v, /run/podman/podman.sock:/var/run/docker.sock:Z, -v, /etc/ssl/private:/certs, portainer/portainer-ce, --sslcert, /certs/fullchain.pem, --sslkey, /certs/privkey.pem ]

First enable the podman socket

sudo systemctl enable --now podman.socket

Connect to the local podman socket

podman run -d -p 9443:9443 --privileged -v /run/podman/podman.sock:/var/run/docker.sock:Z portainer/portainer-ce:2.18.3

Or connect an agent, source: portainer/portainer#2991

podman run -d -p 9001:9001 --name portainer_agent --restart=always -v /var/run/podman/podman.sock:/var/run/docker.sock -v /var/lib/containers/storage/volumes:/var/lib/docker/volumes   portainer/agent:2.18.3

Or, finally, run the portainer edge agent in a podman root environment

podman run -d \
  --privileged \
  -v /run/podman/podman.sock:/var/run/docker.sock:Z \
  -v /var/lib/containers/storage/volumes:/var/lib/docker/volumes \
  -v /:/host \
  -v portainer_agent_data:/data \
  --restart always \
  -e EDGE=1 \
  -e EDGE_ID=23b415af-4e59-42bb-822b-97e3bb919606 \
  -e EDGE_KEY=<EDGE_KEY> \
  -e EDGE_INSECURE_POLL=1 \
  --name portainer_edge_agent \
  portainer/agent:2.18.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment