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.
@hsnyc What is the error message? Is it
SQLSTATE[HY000]  unable to open database file?
http://localhost:8080/install/ in your web browser and than click the button “Login now”. User: 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.
If you want to be able to access the mounted storage folder with your user rights, follow these steps:
- Create the folder
./storage, so you are the owner. Otherwise Docker creates it with root:root permissions.
- Use this
# 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
# mount storage folder into the docker container
# 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")
# 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
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
@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
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.