# Persist storage directory with docker volume

**URL:** <https://discourse.getcockpit.com/t/persist-storage-directory-with-docker-volume/873>\
**Category:** Support\
**Created:** [June 14, 2019, 2:00pm UTC](https://discourse.getcockpit.com/t/persist-storage-directory-with-docker-volume/873 "2019-06-14T14:00:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![flommy](https://avatars.discourse-cdn.com/v4/letter/f/8dc957/32.png) [@flommy](https://discourse.getcockpit.com/u/flommy)\
**Post date:** [June 14, 2019, 2:00pm UTC](https://discourse.getcockpit.com/t/persist-storage-directory-with-docker-volume/873/1 "2019-06-14T14:00:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Blistok](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/blistok/32/212_2.png) [@Blistok](https://discourse.getcockpit.com/u/Blistok)\
**Post date:** [June 14, 2019, 5:23pm UTC](https://discourse.getcockpit.com/t/persist-storage-directory-with-docker-volume/873/2 "2019-06-14T17:23:46Z")

</div>

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:

> <https://gist.github.com/Blistok/9f04e59291e20eb1ca7fa62cc1d98ebc>

---

<div class="post-metadata">

**Author:** ![flommy](https://avatars.discourse-cdn.com/v4/letter/f/8dc957/32.png) [@flommy](https://discourse.getcockpit.com/u/flommy)\
**Post date:** [June 15, 2019, 12:16pm UTC](https://discourse.getcockpit.com/t/persist-storage-directory-with-docker-volume/873/3 "2019-06-15T12:16:43Z")

</div>

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.
