semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Question: Docker Volumes

Open xbc1 opened this issue 2 years ago • 4 comments

Hi, I want to run Semaphore with Docker and I am wondering if there is a Dockerfile available, I can't find one. Wich Directories are used and why? When I run Semaphore with the given compose file there is no Volume specified in the compose file but one is created anyway. I can't seem to find the Files like "project__repository.ibd" wich are present in the Volume Directory on the Host Machine inside the Container, am I missing something?

-Daniel

xbc1 avatar Aug 30 '22 23:08 xbc1

+1

mac-lucky avatar Sep 02 '22 23:09 mac-lucky

Hi @xbc1

Dockerfile in directory: deployment/docker/prod.

fiftin avatar Oct 02 '22 17:10 fiftin

Afaik, the semaphore backend currently doesn't write anything to disk that needs to be persisted.

There is the tmp folder, into which the execution environments for tastks get placed, that one you can configure and could create a host mounted volume for, but I dont thnik that would yield any benefit.

Are you confusing docker with docker compose here? The image produced by the Dockerfile can be pulled by docker pull semaphoreui/semaphore

If you take a look at the Dockerfile at https://github.com/ansible-semaphore/semaphore/blob/develop/deployment/docker/prod/Dockerfile, there is no VOLUME statement there, so it shouldnt create any Volume by itself.

Where do you see these volumes? Did you run a docker inspect? Are the files somewhere in /var/lib/docker/volumes?

If you used the docker-compose.yml from https://docs.ansible-semaphore.com/administration-guide/installation#docker, i suspect the *.idb files you are refering to are index/table data files produced by MySQL, not by the semaphore go backend ;)

DerDummePunkt avatar Oct 03 '22 08:10 DerDummePunkt

If you use BoltDB, as it could be done with the variable --env SEMAPHORE_DB_DIALECT=bolt, you have to create a volume for the BoltDB-data. The data itself is stored in the path /var/lib/semaphore/database.boltdb - if you don't back up this file, most of the done configuration (inventory, repository, task templates, etc.) will be gone after a container restart or update. Therefore, a volume like -v /hostdir:/var/lib/semaphore is needed to save the configuration / database file.

If you use mysql or postgresql this volume configuration doesn't matter.

2302Dave avatar Mar 18 '23 10:03 2302Dave

Container volume doesnt work and fails due to permission issue. Looks like the /var/lib/semaphore is created under user semaphore which is unknown to docker and fails with panic. Apparently config.json created has right permissions, but not the database.bolt file @2302Dave

belibug avatar Sep 11 '23 03:09 belibug

Container volume doesnt work and fails due to permission issue. Looks like the /var/lib/semaphore is created under user semaphore which is unknown to docker and fails with panic. Apparently config.json created has right permissions, but not the database.bolt file @2302Dave

It worked for me as described six month ago. Maybe you could try to create a databasefile with touch and the same permissions as the config.json. Then start the container again.

2302Dave avatar Sep 11 '23 05:09 2302Dave

Container volume doesnt work and fails due to permission issue. Looks like the /var/lib/semaphore is created under user semaphore which is unknown to docker and fails with panic. Apparently config.json created has right permissions, but not the database.bolt file @2302Dave

It worked for me as described six month ago. Maybe you could try to create a databasefile with touch and the same permissions as the config.json. Then start the container again.

I checked again yesterday, both config and db folders are being written under UID 1001, I was able to chown the folder to make it work. But it would be good if it picks up docker run account or has option set UID manually in docker-compose.

belibug avatar Sep 11 '23 11:09 belibug

I checked my configuration. As mentioned in my first post, I just write the db-file. The config doesn't get stored. It worked for me with this workaround.

I believe you could set an user or the uid / gid with --user 1001:1001 as mentioned in this post - https://medium.com/redbubble/running-a-docker-container-as-a-non-root-user-7d2e00f8ee15

2302Dave avatar Sep 11 '23 11:09 2302Dave