Persist storage directory with docker volume

When I try to mount an empty volume to /var/www/html/storage, the dashboard does not load.
Mounting a directory with the standard directories to /var/www/html/storage makes the dashboard load, but collections cannot be created upon save.
And when mounting the /var/www/html, it all seems to work until I restart the container and nothing is persisted.

How can I configure cockpit with a persistent storage directory using docker volume?
My goal is to have cockpit running on google kubernetes with an external mongodb for database.

Welcome @flommy!

Not sure if this will help you, but here’s my docker-compose.yml that persists both uploads and mongodb:

version: "3.7"

services:
  cockpit-mongo:
    image: mongo
    environment:
      MONGO_INITDB_DATABASE: "cockpitmongodb"
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: root
    ports:
      - "27017:27017"
    volumes:
      - /path/on/your/machine:/data/db # Change this to suite your location where the data should be persisted
    networks:
      - cockpit-mongo-net

  qzc-ams-app:
    image: cockpit/dev
    ports:
      - "8080:80"
    volumes:
      - type: bind
        source: ./
        target: /var/www/html
    depends_on:
      - cockpit-mongo
    networks:
      - cockpit-mongo-net

networks:
  cockpit-mongo-net:

Please note that this uses default cockpit/dev docker image so you’ll have first to run npm run docker-init.
I have some setup instructions on this gist if it’s helpful:

1 Like

Hey @Blistok and thanks!

I have extended the agentejo/cockpit image with custom config.php and injecting addons, so I dont believe that the dev image is for me.

In Google Cloud Kubernetes managed to mount a persistent volume to /var/www/html/storage and by setting fsGroup=33 (www-data user in docker image) I could create new collections. The issue seems to have been that the php process inside the container runs as www-data and did not have permissions to create the collections dir in storage.