snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.94k stars 3.16k forks source link

Permission problem with the dockerized snipeit & how to solve it. #11423

Open H4ns906 opened 2 years ago

H4ns906 commented 2 years ago

Debug mode

Describe the bug

This is not really a bug report but more like a "bug and how to fix it" type of report, I dont know if there are other ways to report such thing but here I go. It is my 1st time opening an issue, so my apologies if it doesn't meet the requirements of doing such thing.

I'm trying to test the deployment of snipe-it along with a mariadb database using docker, so it is all local. here is a preview of the compose.yaml I used along with .env files.

image

image

image

after using docker-compose -f compose.yaml up and waiting for the deployment of both containers, I can only access snipeit in my browser after stopping and restarting the snipeit container which is weird. The problem is with volume permissions; the /startup.sh, which is the shell script executed by dockerfile, should normally assign the requiered permissions to the docker user but since the default user declared by Dockerfile is root, there is another process that creates folders in the volume and the docker user cant access them.

To resolve the issue, I logged into the container after everything is up and executed chown -R docker:root /var/www/html/storage/framework/cache which is command you can find in the statup.sh. In the Snipeit doc (not the docker part), it is mentionned that a similar command should be executed but I dont think that would resolve the problem since it doesnt assign the directory to the docker user. here is the reference: image

I'm a newbie but I think the default user should be docker to avoid such problems. please correct me if I'm wrong. Hope this issue helps someone with the same problem.

Reproduction steps

  1. Define the compose.yaml as in the screenshot above.
  2. docker-compose -f compose.yaml up
  3. Wait for the deployement of the containers
  4. docker exec -it snipe-it /bin/bash
  5. chown -R docker:root /var/www/html/storage/framework/cache

Expected behavior

Following the steps above, you should access snipeit from your browser using the APP_URL defined in the .env-snipe

Screenshots

No response

Snipe-IT Version

docker image version for snipeit: 6.0.5; and for mariadb: 10.7.4

Operating System

(managed by Docker, refer to dockerhub)

Web Server

Apache (it is all managed by the container)

PHP Version

(same thing here, it is managed by the container, refer to dockerhub)

Operating System

Ubuntu 22.04 LTS

Browser

opera

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

No response

welcome[bot] commented 2 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

claptrapjargon commented 1 day ago

I am experiencing this issue as well. Using the solution @H4ns906 suggested works for me, I added the following to my compose file: command: ["/bin/sh", "-c", "sleep 10 && exec /startup.sh"]