Bitflake logo

Self-host wallabag with Docker Compose

Read-it-later app that saves web articles in a clean, readable format.

wallabag

wallabag-config-init

busybox

wallabag-data-init

busybox

wallabag-tmp-init

busybox

wallabag-var-init

busybox

The steps below take a few minutes end to end.

  1. Docker compose setup and file
    save the generated compose and env files.
  2. Secret generation
    create the random passwords wallabag needs.
  3. Start wallabag with Docker Compose
    bring the stack up and check it's healthy.

Requirements

You'll need these installed on the machine you're deploying to:

Docker

Packages wallabag and everything it depends on into an isolated container, so it runs the same way on your machine as it does everywhere else.

Install guide

Docker Compose

Reads docker-compose.yml and starts everything in it together. Ships with Docker Desktop. On Linux servers it's usually a separate install.

Install guide

1. Docker compose setup and file

Create a folder for wallabag and save the file below into it as docker-compose.yml. It describes every container the stack needs — wallabag itself and any supporting services, such as its database — along with the ports, volumes and environment variables each one uses. You'll also need an empty .env file in the same folder; Docker Compose reads it automatically and uses it to fill in the ${VARIABLE} references you'll see in the file below.

docker-compose.yml

version: "3.9"
services:
  wallabag:
    image: wallabag/wallabag:latest
    restart: unless-stopped
    ports:
      - 8080:8080
    environment:
      SYMFONY__ENV__DOMAIN_NAME: http://wallabag.localhost:8080
      SYMFONY__ENV__SECRET: ${RANDOM_SYMFONY__ENV__SECRET}
      SYMFONY__ENV__SERVER_NAME: wallabag
    volumes:
      - data:/var/www/wallabag/data
      - config:/var/www/wallabag/app/config
      - var:/var/www/wallabag/var
      - tmp:/tmp
    depends_on:
      wallabag-config-init:
        condition: service_completed_successfully
      wallabag-data-init:
        condition: service_completed_successfully
      wallabag-tmp-init:
        condition: service_completed_successfully
      wallabag-var-init:
        condition: service_completed_successfully
    entrypoint:
      - /bin/sh
      - -c
      - |
        set -e
        cd /var/www/wallabag
        envsubst < /etc/wallabag/parameters.template.yml > app/config/parameters.yml
        mkdir -p data/db data/assets /tmp/nginx
        if [ ! -s data/db/wallabag.sqlite ]; then
          php -d memory_limit=512M bin/console wallabag:install --env=prod -n
          # The non-interactive install always creates wallabag/wallabag.
          php bin/console doctrine:query:sql --env=prod \
            "UPDATE wallabag_user SET username='admin', username_canonical='admin' WHERE username='wallabag'"
          php bin/console fos:user:change-password --env=prod admin Admin123
        fi
        php bin/console cache:warmup --env=prod
        cat > /tmp/php-fpm.conf <<'CONF'
        [global]
        error_log = /proc/self/fd/2
        pid = /tmp/php-fpm.pid
        [www]
        listen = 127.0.0.1:9000
        pm = dynamic
        pm.max_children = 5
        pm.start_servers = 2
        pm.min_spare_servers = 1
        pm.max_spare_servers = 3
        clear_env = no
        php_admin_value[memory_limit] = 256M
        CONF
        cat > /tmp/nginx.conf <<'CONF'
        worker_processes 1;
        pid /tmp/nginx.pid;
        error_log /dev/stderr warn;
        events { worker_connections 1024; }
        http {
          include /etc/nginx/mime.types;
          default_type application/octet-stream;
          access_log off;
          client_max_body_size 100M;
          client_body_temp_path /tmp/nginx/body;
          proxy_temp_path /tmp/nginx/proxy;
          fastcgi_temp_path /tmp/nginx/fastcgi;
          uwsgi_temp_path /tmp/nginx/uwsgi;
          scgi_temp_path /tmp/nginx/scgi;
          map $$http_x_forwarded_proto $$fe_https { default $$https; https on; }
          server {
            listen 8080;
            root /var/www/wallabag/web;
            location / { try_files $$uri /app.php$$is_args$$args; }
            location ~ ^/app\.php(/|$$) {
              fastcgi_pass 127.0.0.1:9000;
              fastcgi_split_path_info ^(.+\.php)(/.*)$$;
              include /etc/nginx/fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $$realpath_root$$fastcgi_script_name;
              fastcgi_param DOCUMENT_ROOT $$realpath_root;
              fastcgi_read_timeout 300s;
              internal;
            }
          }
        }
        CONF
        php-fpm -F -y /tmp/php-fpm.conf &
        exec nginx -e /dev/stderr -c /tmp/nginx.conf -g 'daemon off;'
  wallabag-config-init:
    image: busybox
    volumes:
      - config:/var/www/wallabag/app/config
    command:
      - chown
      - 65534:65534
      - /var/www/wallabag/app/config
  wallabag-data-init:
    image: busybox
    volumes:
      - data:/var/www/wallabag/data
    command:
      - chown
      - 65534:65534
      - /var/www/wallabag/data
  wallabag-tmp-init:
    image: busybox
    volumes:
      - tmp:/tmp
    command:
      - chown
      - 65534:65534
      - /tmp
  wallabag-var-init:
    image: busybox
    volumes:
      - var:/var/www/wallabag/var
    command:
      - chown
      - 65534:65534
      - /var/www/wallabag/var
volumes:
  config: null
  data: null
  tmp: null
  var: null

Volumes

wallabag stores its data in named Docker volumes, so it survives container restarts and updates:

  • data mounted at /var/www/wallabag/data: wallabag's SQLite database and any images it downloads from saved articles.
  • config mounted at /var/www/wallabag/app/config: wallabag's configuration directory. parameters.yml is regenerated from environment variables on every start.
  • var mounted at /var/www/wallabag/var: Symfony's compiled cache, logs, and session files.
  • tmp mounted at /tmp: Generated web server and PHP-FPM configuration, pid files, and upload buffers.

2. Secret generation

wallabag needs a few randomly generated secrets — for example, database passwords or an internal session key — before it can start. These are referenced from docker-compose.yml above but don't live in it, so they need to end up in your .env file. Pick one of the two options below.

Generating secrets…

3. Start wallabag with Docker Compose

From the folder with docker-compose.yml and .env, run:

Terminal

Start wallabag and all its supporting services in the background.

docker compose up -d

The -d flag runs the stack in the background so it keeps running after you close the terminal. Docker will pull the images the first time, which can take a minute or two.

To check on it afterwards: docker compose ps shows whether containers are healthy, and docker compose logs -f follows their logs if something looks wrong. Once it's running, open http://localhost:8080 in your browser.