n8n

DevOps & Automation rootless 2 containers
n8n docker.io/n8nio/n8n:latest · 5678:5678
postgres docker.io/postgres:16

Deployment rootless

1. Prepare the host

Operating System:
!

Prerequisites once as root

Install Podman (needs podman 4.3 or newer; Ubuntu 22.04 ships 3.4 and is too old, use 24.04)

apt update && apt install -y podman

Create user (if not existing)

useradd -m -s /bin/bash n8n
passwd n8n

Enable linger (services keep running after logout and start after reboot)

loginctl enable-linger n8n
↪

Switch to deployment user

su - n8n

Use su - with the dash — this creates a proper login shell as n8n. Without the dash, root environment variables carry over and rootless Podman will not work correctly.

!

Fix environment for rootless systemd (new users only — skip if already set)

Required once so systemctl --user works in non-login sessions.

cat << 'EOF' >> ~/.bashrc

# Fix for systemd user services (rootless Podman/systemctl)
export XDG_RUNTIME_DIR=/run/user/$(id -u)
export DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus
EOF
source ~/.bashrc

2. Choose a format and deploy

The same pod in four forms. Pick one and follow only its steps.

Each tab says which podman it needs. Check yours with podman --version: Debian 12 ships 4.3, Ubuntu 24.04 4.9, Debian 13 5.4, Fedora 5.8, Arch 6.x.

Kubernetes YAML for podman kube play, started by systemd through a Quadlet .kube unit (podman 4.4+; older podman like Debian 12 uses podman-kube@, see the version check below).

Kubernetes YAML

apiVersion: v1
kind: Pod
metadata:
  name: n8n
  labels:
    app: n8n
spec:
  restartPolicy: Always
  containers:
  - name: n8n
    image: docker.io/n8nio/n8n:latest
    imagePullPolicy: Always
    ports:
    - containerPort: 5678
      hostPort: 5678
    env:
    - name: DB_TYPE
      value: postgresdb
    - name: DB_POSTGRESDB_HOST
      value: 127.0.0.1
    - name: DB_POSTGRESDB_PORT
      value: '5432'
    - name: DB_POSTGRESDB_DATABASE
      value: n8n
    - name: DB_POSTGRESDB_USER
      value: n8n
    - name: DB_POSTGRESDB_PASSWORD
      value: kxDdF_OQmjhMAtto4urNvA
    - name: N8N_HOST
      value: localhost
    - name: N8N_PORT
      value: '5678'
    - name: N8N_PROTOCOL
      value: http
    - name: WEBHOOK_URL
      value: http://localhost:5678/
    - name: GENERIC_TIMEZONE
      value: Europe/Vienna
    volumeMounts:
    - name: vol-0
      mountPath: /home/node/.n8n
    securityContext:
      runAsUser: 0
      runAsGroup: 0
  - name: postgres
    image: docker.io/postgres:16
    env:
    - name: POSTGRES_USER
      value: n8n
    - name: POSTGRES_PASSWORD
      value: kxDdF_OQmjhMAtto4urNvA
    - name: POSTGRES_DB
      value: n8n
    volumeMounts:
    - name: vol-1
      mountPath: /var/lib/postgresql/data
    securityContext:
      runAsUser: 999
      runAsGroup: 999
  volumes:
  - name: vol-0
    persistentVolumeClaim:
      claimName: n8n-data
  - name: vol-1
    persistentVolumeClaim:
      claimName: n8n-db
1

Save the YAML file

mkdir -p ~/.config/containers/
nano ~/.config/containers/n8n.yaml
2

Test the pod (without autostart)

podman kube play ~/.config/containers/n8n.yaml

# Check status:
podman pod ps && podman ps

# Stop:
podman kube down ~/.config/containers/n8n.yaml

Check your podman version

podman --version

4.4 or newer: continue with step 3 below.

Older, e.g. 4.3 on Debian 12? There is no Quadlet yet: use podman's own podman-kube@ service instead of steps 3–5
systemctl --user enable --now podman-kube@$(systemd-escape ~/.config/containers/n8n.yaml).service

# Status & logs:
systemctl --user status podman-kube@$(systemd-escape ~/.config/containers/n8n.yaml).service
journalctl --user -u podman-kube@$(systemd-escape ~/.config/containers/n8n.yaml).service -f

The day-to-day commands below have a block for this service.

3

Create Quadlet .kube file

n8n.kube
[Unit]
Description=n8n pod
After=network-online.target
Wants=network-online.target

[Kube]
Yaml=%h/.config/containers/n8n.yaml

[Service]
Restart=always

[Install]
WantedBy=default.target

%h is a systemd home-directory specifier — do not replace it with ~/.

Save to ~/.config/containers/systemd/:

mkdir -p ~/.config/containers/systemd/
nano ~/.config/containers/systemd/n8n.kube
4

Start systemd service

systemctl --user daemon-reload
systemctl --user start n8n.service
5

Status & Logs

systemctl --user status n8n.service
journalctl --user -u n8n.service -f
podman pod ps
podman ps
6

Enable automatic image updates optional

Requires AutoUpdate=registry in the .kube file. Podman then checks for new images and restarts the pod automatically:

systemctl --user enable --now podman.socket
systemctl --user daemon-reload
systemctl --user enable --now podman-auto-update.timer

# Check status:
systemctl --user status podman-auto-update.timer

# Trigger manually:
podman auto-update
Day-to-day logs, restart, update, remove (click to open)

Logs & shell into a container

podman logs -f n8n-n8n
podman logs -f n8n-postgres
podman exec -it n8n-n8n /bin/sh

Restart

systemctl --user restart n8n.service

Update an image by hand

Pull the new version, the restart recreates the containers from it:

podman pull <image>:<tag>
systemctl --user restart n8n.service

Stop & remove

Stop through systemd, otherwise Restart=always brings the pod back. To remove it for good, delete the unit files and reload:

systemctl --user stop n8n.service
rm ~/.config/containers/systemd/n8n.kube
systemctl --user daemon-reload

podman older than 4.4 (podman-kube@ from step 3)

systemctl --user restart podman-kube@$(systemd-escape ~/.config/containers/n8n.yaml).service

# Update an image: pull, then restart as above
podman pull <image>:<tag>

# Stop and remove from autostart:
systemctl --user disable --now podman-kube@$(systemd-escape ~/.config/containers/n8n.yaml).service

Delete the data — permanent, only after stop & remove

podman volume rm n8n-data
podman volume rm n8n-db

Native systemd units without the Kubernetes YAML: one .pod plus one .container per container. Each container becomes its own systemd service (restart, logs and ordering per container). Needs podman 5.0 or newer — Debian 12 ships 4.3, use the Kube YAML tab there.

1

Save the unit files

n8n.pod
[Unit]
Description=n8n pod

[Pod]
PodName=n8n
PublishPort=5678:5678
n8n-n8n.container
[Unit]
Description=n8n-n8n container

[Container]
Image=docker.io/n8nio/n8n:latest
Pod=n8n.pod
ContainerName=n8n-n8n
Pull=always
Environment=DB_TYPE=postgresdb
Environment=DB_POSTGRESDB_HOST=127.0.0.1
Environment=DB_POSTGRESDB_PORT=5432
Environment=DB_POSTGRESDB_DATABASE=n8n
Environment=DB_POSTGRESDB_USER=n8n
Environment=DB_POSTGRESDB_PASSWORD=kxDdF_OQmjhMAtto4urNvA
Environment=N8N_HOST=localhost
Environment=N8N_PORT=5678
Environment=N8N_PROTOCOL=http
Environment=WEBHOOK_URL=http://localhost:5678/
Environment=GENERIC_TIMEZONE=Europe/Vienna
Volume=n8n-data:/home/node/.n8n:Z
User=0
Group=0

[Service]
Restart=always

[Install]
WantedBy=default.target
n8n-postgres.container
[Unit]
Description=n8n-postgres container

[Container]
Image=docker.io/postgres:16
Pod=n8n.pod
ContainerName=n8n-postgres
Environment=POSTGRES_USER=n8n
Environment=POSTGRES_PASSWORD=kxDdF_OQmjhMAtto4urNvA
Environment=POSTGRES_DB=n8n
Volume=n8n-db:/var/lib/postgresql/data:Z
User=999
Group=999

[Service]
Restart=always

[Install]
WantedBy=default.target

Save all of them to ~/.config/containers/systemd/:

mkdir -p ~/.config/containers/systemd/
nano ~/.config/containers/systemd/n8n.pod
nano ~/.config/containers/systemd/n8n-n8n.container
nano ~/.config/containers/systemd/n8n-postgres.container
2

Start the pod

The pod service pulls in every container service. Autostart at boot comes from the [Install] section of the units, no enable needed.

systemctl --user daemon-reload
systemctl --user start n8n-pod.service
3

Status & Logs

systemctl --user status n8n-pod.service
journalctl --user -u n8n-n8n.service -f
journalctl --user -u n8n-postgres.service -f
podman pod ps && podman ps
Day-to-day logs, restart, update, remove (click to open)

Logs & shell into a container

podman logs -f n8n-n8n
podman logs -f n8n-postgres
podman exec -it n8n-n8n /bin/sh

Restart

systemctl --user restart n8n-pod.service

Update an image by hand

Pull the new version, the restart recreates the containers from it:

podman pull <image>:<tag>
systemctl --user restart n8n-pod.service

Stop & remove

Stop through systemd, otherwise Restart=always brings the pod back. To remove it for good, delete the unit files and reload:

systemctl --user stop n8n-pod.service
rm ~/.config/containers/systemd/n8n.pod
rm ~/.config/containers/systemd/n8n-n8n.container
rm ~/.config/containers/systemd/n8n-postgres.container
systemctl --user daemon-reload

Delete the data — permanent, only after stop & remove

podman volume rm n8n-data
podman volume rm n8n-db

A docker-compose.yml for podman-compose. Handy if you already work with Compose; there are no per-container systemd services.

1

Install podman-compose as root

Run this as root, e.g. together with the prerequisites before su - n8n.

apt install -y podman-compose
2

Save the compose file

docker-compose.yml
services:
  n8n:
    image: docker.io/n8nio/n8n:latest
    pull_policy: always
    restart: always
    environment:
    - DB_TYPE=postgresdb
    - DB_POSTGRESDB_HOST=127.0.0.1
    - DB_POSTGRESDB_PORT=5432
    - DB_POSTGRESDB_DATABASE=n8n
    - DB_POSTGRESDB_USER=n8n
    - DB_POSTGRESDB_PASSWORD=kxDdF_OQmjhMAtto4urNvA
    - N8N_HOST=localhost
    - N8N_PORT=5678
    - N8N_PROTOCOL=http
    - WEBHOOK_URL=http://localhost:5678/
    - GENERIC_TIMEZONE=Europe/Vienna
    user: 0:0
    depends_on:
      postgres:
        condition: service_started
    volumes:
    - n8n-data:/home/node/.n8n:Z
    network_mode: service:postgres
  postgres:
    image: docker.io/postgres:16
    restart: always
    environment:
    - POSTGRES_USER=n8n
    - POSTGRES_PASSWORD=kxDdF_OQmjhMAtto4urNvA
    - POSTGRES_DB=n8n
    user: 999:999
    volumes:
    - n8n-db:/var/lib/postgresql/data:Z
    ports:
    - 5678:5678
volumes:
  n8n-data: null
  n8n-db: null
mkdir -p ~/n8n
nano ~/n8n/docker-compose.yml
3

Start, status & logs

cd ~/n8n
podman-compose up -d
podman-compose ps
podman-compose logs -f

# Stop:
podman-compose down
4

Start after reboot

podman-restart.service starts every container with restart: always at boot:

systemctl --user enable podman-restart.service
5

Update images

cd ~/n8n
podman-compose pull
podman-compose up -d
Day-to-day logs, restart, update, remove (click to open)

Logs & shell into a container

podman logs -f n8n_n8n_1
podman logs -f n8n_postgres_1
podman exec -it n8n_n8n_1 /bin/sh

Restart

cd ~/n8n
podman-compose restart

Stop & remove

cd ~/n8n
podman-compose down

Delete the data — permanent, only after stop & remove

podman volume rm n8n_n8n-data
podman volume rm n8n_n8n-db

Plain podman pod create / podman create commands. Good for a quick test or to see what happens under the hood.

1

Save the script

n8n.sh
#!/bin/bash
set -e

# ── Create named volumes ───────────────────────────────────────────
# Named volumes are created automatically — no UID/GID permission adjustment needed.
podman volume exists n8n-data || podman volume create n8n-data
podman volume exists n8n-db || podman volume create n8n-db

# ── Create pod ─────────────────────────────────────────────────────
podman pod create \
  --name n8n \
  -p 5678:5678

# ── Container: n8n-n8n ─────────────────────────────────────────────
podman create \
  --pod n8n \
  --name n8n-n8n \
  --restart always \
  --pull always \
  -e DB_TYPE='postgresdb' \
  -e DB_POSTGRESDB_HOST='127.0.0.1' \
  -e DB_POSTGRESDB_PORT='5432' \
  -e DB_POSTGRESDB_DATABASE='n8n' \
  -e DB_POSTGRESDB_USER='n8n' \
  -e DB_POSTGRESDB_PASSWORD='kxDdF_OQmjhMAtto4urNvA' \
  -e N8N_HOST='localhost' \
  -e N8N_PORT='5678' \
  -e N8N_PROTOCOL='http' \
  -e WEBHOOK_URL='http://localhost:5678/' \
  -e GENERIC_TIMEZONE='Europe/Vienna' \
  -v n8n-data:/home/node/.n8n:Z \
  --user 0:0 \
  docker.io/n8nio/n8n:latest

# ── Container: n8n-postgres ─────────────────────────────────────────────
podman create \
  --pod n8n \
  --name n8n-postgres \
  --restart always \
  -e POSTGRES_USER='n8n' \
  -e POSTGRES_PASSWORD='kxDdF_OQmjhMAtto4urNvA' \
  -e POSTGRES_DB='n8n' \
  -v n8n-db:/var/lib/postgresql/data:Z \
  --user 999:999 \
  docker.io/postgres:16

# ── Start pod ──────────────────────────────────────────────────────
podman pod start n8n

# ── Stop & clean up ───────────────────────────────────────────────
# podman pod stop n8n
# podman pod rm n8n
nano n8n.sh
2

Run it, status & logs

bash n8n.sh
podman pod ps && podman ps
podman logs -f <container-name>
3

Start after reboot

podman-restart.service starts every container with --restart always at boot:

systemctl --user enable podman-restart.service
4

Remove or rebuild

The script creates the pod once. To apply changes or new images, remove the pod and run the script again (named volumes stay):

podman pod rm -f n8n
bash n8n.sh
Day-to-day logs, restart, update, remove (click to open)

Logs & shell into a container

podman logs -f n8n-n8n
podman logs -f n8n-postgres
podman exec -it n8n-n8n /bin/sh

Restart

podman pod stop n8n
podman pod start n8n

Stop & remove

podman pod rm -f n8n

Delete the data — permanent, only after stop & remove

podman volume rm n8n-data
podman volume rm n8n-db

Ports < 1024 (e.g. 80, 443)

Rootless cannot open privileged ports. Solution:

sysctl net.ipv4.ip_unprivileged_port_start=80

Make persistent in /etc/sysctl.d/99-podman.conf.

Containers communicate via localhost

All containers in the pod share the same network namespace. Always use localhost, not container names.

# Correct (e.g. app → db):
localhost:5432

# Wrong (doesn't work in a pod):
db-container:5432

List open ports

Which ports are the running containers publishing? See the PORTS column:

podman ps

Custom DNS for the pod

Set a custom DNS server (e.g. local Pi-hole) in the generator under DNS server. Every format picks it up.

Set volume ownership

Fix permission errors by adjusting UID/GID in the user namespace:

podman unshare chown 1000:1000 /path/to/volume

SELinux volume labels

On SELinux systems (RHEL, Fedora) set the volume suffix:

/host/path:/container/path:Z   # private
/host/path:/container/path:z   # shared

List all volumes

podman volume ls
podman volume inspect <volume-name>

Volume backup

Back up data from a named volume:

podman run --rm \
  -v <volume-name>:/data:ro \
  -v $(pwd):/backup \
  busybox tar czf /backup/backup.tar.gz /data

Cleanup

Remove unused images, containers and volumes:

podman system prune -f        # containers + images
podman image prune -f         # untagged images only
podman volume prune -f        # unused volumes

Check for outdated images

List local images; auto-update only covers units with AutoUpdate= (Kube and Quadlet tabs):

podman images
podman auto-update --dry-run

All containers, including stopped ones

podman pod ps
podman ps -a

Resource usage

podman stats --no-stream

Customize this stack
Change ports, volumes, environment variables and more in the generator.
Open in Generator