Running a Rootless Podman Web App with Persistent Volumes on Ubuntu

Ubuntu 24.04 LTS ships with Podman 4.8 straight from the official repos, which makes it a solid choice for a lightweight, root‑less container runtime. Rootless mode means you never have to type sudo, and the container stays inside your own user namespace – a big win for home labs and self‑hosted services.

Below is a step‑by‑step walk‑through that pulls the popular Ghost blogging platform, runs it in rootless Podman, and keeps its data in a bind mount. The same pattern works for any stateless or stateful web service you want to host.

Why rootless?
Running containers as a regular user removes the privilege escalation that Docker forces. It also shrinks the attack surface: if a container gets compromised, the attacker is stuck in your user namespace.


1. Prepare the host

sudo apt update
sudo apt install -y podman git

The first time you use Podman, it runs a helper script that creates the user‑namespace configuration. Just fire it up:

podman machine init

When prompted about setting up a rootless user, say yes. It will create a .config/containers directory in your home folder with the default configuration.

Tip: On Ubuntu 24.04 the default containers.conf already sets cgroup_manager = "systemd", which is what we want for rootless containers.


2. Create a project directory

Keeping everything under one folder makes version‑control and later relocation a breeze.

mkdir -p ~/webapps/ghost
cd ~/webapps/ghost

Inside this folder we’ll keep:

  • docker-compose.yml – a quick way to describe the service.
  • data/ – the persistent volume.
  • podmanfile – optional, if you want a custom image.

Create the data directory:

mkdir data

3. Pull the Ghost image

Ghost is published on Docker Hub as ghost:5. Podman can pull Docker Hub images directly.

podman pull docker.io/ghost:5

If you want a leaner image, swap in ghost:5-alpine. It starts faster and uses less space.


4. Run the container with a bind mount

The trick to persistence is mounting the host directory into the container’s /var/lib/ghost/content path. Ghost stores its configuration, posts, and media there.

podman run -d \
  --name ghost \
  -p 8080:2368 \
  -v "$(pwd)/data:/var/lib/ghost/content" \
  docker.io/ghost:5
Flag Meaning
-d Run in the background.
--name ghost Give the container a readable name.
-p 8080:2368 Map host port 8080 to Ghost’s default port 2368.
-v "$(pwd)/data:/var/lib/ghost/content" Bind‑mount the local data directory into the container.

After a few seconds you can hit http://localhost:8080 and finish the Ghost setup wizard. All posts and uploads will now live in ~/webapps/ghost/data.


5. Managing the container

Rootless Podman behaves like Docker for the most part, so the familiar syntax works:

# Stop
podman stop ghost

# Start
podman start ghost

# View logs
podman logs -f ghost

# Remove
podman rm ghost

If you pull a newer image or change the configuration, stop and remove the old container first, then run the podman run command again.


6. Using podman compose

When you need more than one service, environment variables, or network isolation, podman compose is the drop‑in replacement for Docker Compose.

Create a docker-compose.yml in the project folder:

version: "3.9"
services:
  ghost:
    image: docker.io/ghost:5
    container_name: ghost
    ports:
      - "8080:2368"
    volumes:
      - ./data:/var/lib/ghost/content
    restart: unless-stopped

Start the stack:

podman compose up -d

Stop it:

podman compose down

No extra configuration is needed – podman compose automatically runs in the rootless namespace.


7. Security considerations

Area Recommendation
User namespace Rootless mode already limits the container to your user.
File permissions The bind mount inherits the host directory’s permissions. Make sure data/ is owned by your user and not world‑writable.
Network By default Podman exposes the container to the host network. If you want tighter isolation, use --network podman or create a dedicated network.
Updates Keep the image fresh: podman pull docker.io/ghost:5 && podman compose up -d --force-recreate.
Secrets Store API keys or database passwords in environment variables or a .env file, not in the image.

8. Common pitfalls and how to fix them

Symptom Likely cause Fix
Container exits immediately Wrong volume path or missing permissions Verify data/ exists and is writable.
Ghost cannot write to /var/lib/ghost/content AppArmor restrictions Ubuntu’s default AppArmor profile allows write access; if you’re on a custom profile, adjust it or use --security-opt label=disable.
Port conflict on 8080 Another service listening Change the host port in the -p flag or docker-compose.yml.
Slow first start Large image layers Use ghost:5-alpine or pre‑pull the image.

9. Scaling up: adding a database

Ghost can talk to an external database (PostgreSQL, MySQL). Here’s a quick example using PostgreSQL in another rootless container.

Create a docker-compose.yml that includes both services:

services:
  ghost:
    image: docker.io/ghost:5
    container_name: ghost
    environment:
      - url=http://localhost:8080
      - database__client=pg
      - database__connection__host=db
      - database__connection__user=ghost
      - database__connection__password=secret
      - database__connection__database=ghost
    ports:
      - "8080:2368"
    volumes:
      - ./data:/var/lib/ghost/content
    depends_on:
      - db
    restart: unless-stopped

  db:
    image: docker.io/postgres:15
    container_name: ghost-db
    environment:
      - POSTGRES_USER=ghost
      - POSTGRES_PASSWORD=secret
      - POSTGRES_DB=ghost
    volumes:
      - ./db-data:/var/lib/postgresql/data
    restart: unless-stopped

Run:

podman compose up -d

Now Ghost will use PostgreSQL for persistence, while the data/ folder still holds the content files.


10. Backing up and restoring

Because all persistent data lives in the host directories (data/ and db-data/), backing up is as simple as archiving those folders.

tar czf ghost-backup-$(date +%F).tar.gz data db-data

Restore by extracting into the same project directory and restarting the stack.


11. Performance notes

Rootless Podman uses user namespaces and a user‑level cgroup hierarchy. On Ubuntu 24.04 the default cgroup_manager = "systemd" gives good isolation without the overhead of a separate kernel cgroup driver. For very high‑throughput services you might consider:

  • Switching to cgroup_manager = "cgroupfs" for tighter control (but it needs extra setup).
  • Using the --memory and --cpus flags to limit resource usage.

12. When to switch to Docker

If you need:

  • Docker‑specific features (e.g., Docker‑Compose v2 plugins, Docker Hub build secrets).
  • Enterprise tooling that only supports Docker.

Then Docker may be the better choice. For most home‑lab and self‑hosting scenarios, rootless Podman is simpler, more secure, and fully compatible with Docker images.


13. Final checklist

  • Installed Podman and verified rootless mode.
  • Created a project directory with a persistent volume.
  • Pulled the desired image (ghost:5).
  • Ran the container with a bind mount.
  • Tested the web interface.
  • Added a database (optional).
  • Set up a backup strategy.
  • Monitored logs and resource usage.

See also