# Docker Compose file for Cockpit with SQLite file mount

**URL:** <https://discourse.getcockpit.com/t/docker-compose-file-for-cockpit-with-sqlite-file-mount/1573>\
**Category:** Support\
**Created:** [August 8, 2020, 3:07am UTC](https://discourse.getcockpit.com/t/docker-compose-file-for-cockpit-with-sqlite-file-mount/1573 "2020-08-08T03:07:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hsnyc](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/hsnyc/32/663_2.png) [@hsnyc](https://discourse.getcockpit.com/u/hsnyc)\
**Post date:** [August 8, 2020, 3:07am UTC](https://discourse.getcockpit.com/t/docker-compose-file-for-cockpit-with-sqlite-file-mount/1573/1 "2020-08-08T03:07:37Z")

</div>

Hi, I am looking for help setting a docker-compose.yml file to run Cockpit in docker container with access to the SQLite /storage container volume. I am not an expert in Docker so looking for some help. I am trying this simple starter but it will throw errors when I start the container. Any help would be appreciated.

```
version: "3.7"

services:
  cockpit:
    image: agentejo/cockpit
    volumes:
      - ./storage:/var/www/html/storage
    ports:
      - 8080:80
```

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [August 10, 2020, 1:00pm UTC](https://discourse.getcockpit.com/t/docker-compose-file-for-cockpit-with-sqlite-file-mount/1573/2 "2020-08-10T13:00:43Z")

</div>

@hsnyc What is the error message? Is it `SQLSTATE[HY000] [14] unable to open database file`?

**Short answer:**  
Run `http://localhost:8080/install/` in your web browser and than click the button “Login now”. User: admin  
Password: admin

**Medium sized answer:**  
The data folder doesn’t exist or is not writable. When calling `/install`, the data folder (and cache, thumbs, tmp, uploads) inside `./storage` are created on the fly with apache permissions 33:33.

**Long answer:**  
If you want to be able to access the mounted storage folder with your user rights, follow these steps:

1. Create the folder `./storage`, so you are the owner. Otherwise Docker creates it with root:root permissions.
2. Use this `docker-compose.yml`:

```auto
version: "3.7"

services:
  cockpit:

    # https://hub.docker.com/r/agentejo/cockpit
    # https://github.com/agentejo/cockpit-docker
    image: agentejo/cockpit

    # let apache create files and folders with your user_id:user_group_id
    # In my case, I'm the default user with id 1000 and I'm a member of the group with gid 1000
    user: 1000:1000

    volumes:
      # mount storage folder into the docker container
      - ./storage:/var/www/html/storage

    ports:
      - 8080:80

    # apache can't start without that fix if the user was changed
    # see https://hub.docker.com/_/php/ (scroll down to "Running as an arbitrary user")
    sysctls:
      - net.ipv4.ip_unprivileged_port_start=0

    # override the entrypoint, that tries to change the ownership to 33:33 after the container started
    # see https://github.com/agentejo/cockpit-docker/blob/master/entrypoint#L5
    entrypoint: ["apache2-foreground"]

```

1. Run `docker-compose up` or `docker-compose up -d` to start the container. You should be able to access and write all files in the mounted storage folder.

Tested on OpenSUSE (latest) with Docker version 19.03.12

---

<div class="post-metadata">

**Author:** ![hsnyc](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/hsnyc/32/663_2.png) [@hsnyc](https://discourse.getcockpit.com/u/hsnyc)\
**Post date:** [August 15, 2020, 5:33pm UTC](https://discourse.getcockpit.com/t/docker-compose-file-for-cockpit-with-sqlite-file-mount/1573/3 "2020-08-15T17:33:01Z")

</div>

@raffaelj Thank you do much for your reply. Your short answer helped me resolved the issue. For some reason, it showed an error the first time I tried login in (wish I’ve taken a screenshot). When I got your reply I tried it again and it worked fine. Perhaps because I have re-started the Docker Desktop service? not sure… in any case thank you for your detailed reply 🙂

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [August 15, 2020, 9:03pm UTC](https://discourse.getcockpit.com/t/docker-compose-file-for-cockpit-with-sqlite-file-mount/1573/4 "2020-08-15T21:03:10Z")

</div>

> [@hsnyc](#):
>
> Perhaps because I have re-started the Docker Desktop service?

Maybe, but if you didn’t change anything inbetween, the error should still occur. I always have that error message after starting a fresh container with an empty storage volume.  
If you don’t use the storage volume, the needed folder exists → no error message.  
If you create all needed folders before mounting them into the image → no error message.  
If you run the install routine, the folders are created and there is no error message anymore.  
That’s, how I was able to reproduce it.

Anyway. I’m glad, I was able to help.
