Possible to add default data-scheme to Docker image?

We have our project running on different servers using the provided cockpit Docker image. Now on all these servers, we need the same data-structure in cockpit (currently about 2 singletons and 2 collections).
Is it possible to add the data-scheme somehow to the Docker image, so that we don’t have to setup cockpit every single time?


1 Like

I’m trying to achieve the same thing. Did you find a solution? Thanks

@tommueller, @gnagnu Can you explain your use cases with some more details, please? Do you need only the structure (/storage/collections/*.php and /storage/singletons/*.php) or also some default data in the database? Data might need some importing scripts…

Some possible solutions:

You could create your own Docker image with the existing files and use that instead. Something like this:

Folder structure:

FROM agentejo/cockpit

COPY ./default.collection.php /var/www/html/storage/collections/default.collection.php

Or you could mount your default files into the container.

docker run -d --name cockpit -p 8080:80 agentejo/cockpit -v "$PWD"/default.collection.php:/var/www/html/storage/collections/default.collection.php


version: "3.7"

    image: agentejo/cockpit
      - ./storage:/var/www/html/storage
      - ./default.collection.php:/var/www/html/storage/collections/default.collection.php
      - 8080:80

Thanks @raffaelj!

The use case is, that we are providing a white-label software, that can be filled with content provided by cockpit. So for every new customer, we set up a new server, and run our software there, including cockpit, which runs within docker.

Now to net have to setup the singletons and collections with all the fields every time by hand, it would be nice to have a way to already include this into the docker image. Your first suggestions seems like it could work.

I thought that cockpit was using sqllite?! But collections and singleton schemas are stored in php files? Is there documentation about this somewhere?

Thanks! Tom

Yes. Only the data is stored in databases (MongoDB or SQLite). All the definition files are stored in

  • /storage/collections/*.collection.php
  • /storage/singleton/*.singleton.php
  • /storage/forms/*.form.php

Data are things like

  • users, some addon config, dashboard settings… - /storage/data/cockpit.sqlite
  • collection entries - /storage/data/collections.sqlite
  • singleton data - /storage/data/cockpitdb.sqlite
  • form submissions - /storage/data/forms.sqlite
  • locked entries (multi user setup) - /storage/data/cockpit.memory.sqlite

Good question :wink: I don’t think so, but now you know it.

Thanks a bunch! That will be sufficient to get somewhere I guess.

It’ll take a while until I will find the time to implement it, but when I do I will try to leave some code here @gnagnu

Thanks both! Very useful info