Docker Unable to create the "cache" directory (/var/www/wallabag/var/cache/prod).
Environment
- Version: docker wallabag/wallabag:2.5.4
- Installation: docker
- PHP version:
- OS: alpine 3.17.0 root
- Database: sqlite
- Parameters:
What steps will reproduce the bug?
When I execute the following command as root on Alpine
docker run -it -p 7004:80 wallabag.wallabag:2.5.4
I'm seeing the exact same problem since 2.5.4. Any advice or updates on this?
I know its been a while.. got the same issue on alpine, keep getting unable to create the "cache" directory periodically, anyone...?
Workaround: Permission denied during Wallabag Docker setup (rootless / nobody user)
If your Wallabag container fails during the initial setup with errors like:
file_put_contents(app/config/parameters.yml): Failed to open stream: Permission denied
Unable to create the "cache" directory (/var/www/wallabag/var/cache/prod).
it may be because parts of Wallabag’s setup run as the nobody user inside the container, but the Symfony directories are owned by root (or another user), so nobody can’t write to them.
Below are two ways to fix this.
Option 1: Quick one-off fix (chown after docker compose up)
Bring up Wallabag as usual:
docker compose up -d wallabag
Before the setup step runs (or if it’s already failed once), run:
docker exec -it wallabag sh -lc '
cd /var/www/wallabag &&
chown -R nobody:nobody app/config var data web
'
This changes ownership of the key Symfony/Wallabag directories so the nobody user can write to them. After this, you should be able to complete the setup in the browser without the permission errors.
Option 2: Build a custom image with the fix baked in
If you prefer something more permanent, you can build a small wrapper image that fixes the ownership at build time.
mkdir -p /mnt/storage/wallabag-custom
cd /mnt/storage/wallabag-custom
cat > Dockerfile <<'EOF'
FROM wallabag/wallabag:latest
# Fix ownership so the "nobody" user that runs composer/cache
# can write to the Symfony/Wallabag directories.
RUN chown -R nobody:nobody \
/var/www/wallabag/app/config \
/var/www/wallabag/var \
/var/www/wallabag/data \
/var/www/wallabag/web
EOF
Build the image:
docker build -t wallabag-nobodyfix:latest .
Then in your docker-compose.yml, use the custom image instead of the upstream one:
services:
wallabag:
image: wallabag-nobodyfix:latest
# ...the rest of your config (env, volumes, etc.)
Redeploy:
docker compose up -d wallabag
This way, every time the container starts, the directories already have the correct ownership for the nobody user, and the setup phase should complete without permission issues.