is there a way to run to run the Ghost server, database, activity pub, and analytics containers as rootless? I’m a little concerned about having this much code running as root, since an exploit to any of these components could result in a complete compromise of my system. I’m especially concerned since the Docker versions of Ghost have repeatedly been left without updates for security vulnerabilities.
I’m willing to set everything from scratch, if it means I can run Ghost and its associated services rootless. Is running Ghost in rootless containers supported?
Only modification to the default deployment is that Docker deployment is that I commented out lines associated with Caddy, since I already had a different reverse proxy set up.
Base OS is Arch Linux, using Docker version 29.3.0, build 5927d80c76, Docker Compose version 5.1.0.
For the original question: As a complement of @markstos detailed answer, I also suggest running Docker itself in rootless mode. More info in Docker Docs or consider Podman instead of Docker, if you are willing to spend a little more time configuring/maintaining at the benefit of “native” or “out of the box” hardened features.
Thank you for all the suggestions. I will wait for the officially supported Docker Compose version to get a rootless version. I will take a look at Podman, but it seems that some of the other software I run doesn’t have official Podman support.
I’m a fan of Podman– it’s what I use myself to run Ghost. But systemd doesn’t support running Podman rootless if you try to run Podman as a rootful systemd service with a User= directive. There’s an extremely long thread about problems and workarounds that people have for that:
You can run Podman as a systemd user service, which has it’s on challenges for management.
But running the container with a –user= directive or with a container that runs as non-root user internally, as Ghost-on-Kubernetes container does (and the official Ghost container reportedly will do) achieves a similar result– that the Ghost process is not running as root.
I agree and I felt a bit dumb when you shared your approach with systemd units because I never thought about that method before, and it’s pretty clever.
Oftebly we forget that at the vase, containers are chroots on steroids hahaha
In case anyone is interested, this is the compose file I’ve ended up using for my rootless deployment of Ghost under rootful Docker. I’ve tried switching to Podman, but kept having networking performance issues related to Pasta (Podman’s networking implementation), and database connection failures (potentially related to ghost-docker #127).
My config doesn’t use the usual Caddy container, since I use a separate NGINX reverse proxy. If you intend to run Caddy rootless, you might have to give it the CAP_NET_BIND_SERVICE capability, since ports 80 and 443 require privileged access.
I’ve had to change the perms on the data directory to make data/ghost to be owned by the user I have the Ghost container running under; and to change the data/mysql directory to be owned by 999:adm.
If anyone wants to upstream my changes or findings into Ghost, or the Ghost docs, you are welcome to do so.