Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Permission error #30

Closed
P4sca1 opened this issue Jan 31, 2018 · 12 comments
Closed

Permission error #30

P4sca1 opened this issue Jan 31, 2018 · 12 comments

Comments

@P4sca1
Copy link
Contributor

P4sca1 commented Jan 31, 2018

I'm getting permission errors when starting the bot.

Here's the full log:

-> Updating sinusbot user and group id if necessary ...
-> Correcting file and mount point permissions ...
=> Corrected mount point permissions.
-> Checking if scripts directory is empty
-> Copying original sinusbot scripts to volume ...
cp: cannot create regular file '/sinusbot/scripts/advertising.js': Permission denied
cp: cannot create regular file '/sinusbot/scripts/alonemode.js': Permission denied
cp: cannot create regular file '/sinusbot/scripts/bookmark.js': Permission denied
cp: cannot create regular file '/sinusbot/scripts/followme.js': Permission denied
cp: cannot create regular file '/sinusbot/scripts/norecording.js': Permission denied
cp: cannot create regular file '/sinusbot/scripts/rememberChannel.js': Permission denied
cp: cannot create regular file '/sinusbot/scripts/welcome.js': Permission denied
touch: cannot touch '/sinusbot/scripts/.docker-sinusbot-installed': Permission denied
=> Sinusbot scripts copied.
-> Checking for old data location ...
=> You are good to go! You are already using the new data directory, located at "/sinusbot/data".
=> Updating Youtube-dl...
youtube-dl is up-to-date (2018.01.27)
=> Updated youtube-dl with exit code 0
=> Starting SinusBot (https://sinusbot.com) by Michael Friese ...
Error: Could not create directory /sinusbot/data//db; mkdir /sinusbot/data//db: permission denied

I started the container with the following command:

docker container run --name sinusbot --mount type=bind,src=/Users/pascal/Sinusbot/data,dst=/sinusbot/data --mount type=bind,src=/Users/pascal/Sinusbot/scripts,dst=/sinusbot/scripts -p 8087:8087 galexrt/sinusbot

I set the owner and user of the mounted paths to 3000:

ls -l /Users/pascal/Sinusbot
total 0
drwxr-xr-x  2 3000  3000  64 31 Jan 11:04 data
drwxr-xr-x  2 3000  3000  64 31 Jan 11:04 scripts

I hope somebody can help me fixing the problem.

Regards,
Pascal

@galexrt
Copy link
Owner

galexrt commented Jan 31, 2018

Can you please write on which OS and platform you are running on?
Also which docker version would be good.

@P4sca1
Copy link
Contributor Author

P4sca1 commented Jan 31, 2018

I'm running Mac OS X 10.13.2.

My docker version:

Client:
 Version:	17.12.0-ce
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	c97c6d6
 Built:	Wed Dec 27 20:03:51 2017
 OS/Arch:	darwin/amd64

Server:
 Engine:
  Version:	17.12.0-ce
  API version:	1.35 (minimum version 1.12)
  Go version:	go1.9.2
  Git commit:	c97c6d6
  Built:	Wed Dec 27 20:12:29 2017
  OS/Arch:	linux/amd64
  Experimental:	true

@galexrt
Copy link
Owner

galexrt commented Jan 31, 2018

Please run the following commands post their output.

docker pull galexrt/sinusbot:latest
docker container run --name sinusbot --volume /Users/pascal/Sinusbot/data:/sinusbot/data --volume /Users/pascal/Sinusbot/scripts:/sinusbot/scripts -p 8087:8087 galexrt/sinusbot

The run command uses --volume instead of --mount that you used.
For me both --volume and --mount versions work, but I'm on linux/amd64 for client and server.

@P4sca1
Copy link
Contributor Author

P4sca1 commented Jan 31, 2018

Thank you for your answer!

The output of running the container is the same as before.

This is the output of docker pull:

latest: Pulling from galexrt/sinusbot
Digest: sha256:9aa42539b4bca802ad10c234d30b4afe4967d9b6b01e910fa8747aae015236b1
Status: Image is up to date for galexrt/sinusbot:latest

Could it be that user groups / ids are not preserved correctly when mounting from my mac to the linux container?

@P4sca1
Copy link
Contributor Author

P4sca1 commented Jan 31, 2018

moby/moby#22258 (comment) :

docker4mac is a slightly difference case since it does map UID/GID into the UID/GID that the container process was started with.

Maybe this has something to do with the problem?

@galexrt
Copy link
Owner

galexrt commented Jan 31, 2018

@P4sca1 The moby/moby issue you posted, could potentially be the problem.
From what I understand you need to start/run docker4mac as root as currently root user is used for the initial start script of Sinusbot.
But if I hopefully find the time I will look into dropping root user usage on the weekend. This may fix your issue.

@P4sca1
Copy link
Contributor Author

P4sca1 commented Jan 31, 2018

@galexrt Running the docker container as root does not fix the issue, same error like before. Aren't the scripts already copied as the sinusbot user?

@galexrt
Copy link
Owner

galexrt commented Jan 31, 2018

I have modified the image to directly use the sinusbot user created inside the image.
The "only" requirement is to have the data and scripts directory on the host (when used) chowned to 3000.

Please repull the image and let me know if that fixes the issue for your.

Also the README.md has been updated with more info on data persistence (with example chown commands, etc).

@P4sca1
Copy link
Contributor Author

P4sca1 commented Feb 1, 2018

I pulled the newest image and started the container, but I still have the same issue. The directories are chowned to 3000:3000.

@P4sca1
Copy link
Contributor Author

P4sca1 commented Feb 1, 2018

I was able to start the container when setting the ownership of the mounted folders to the user starting the docker container. The reason why it works like this seems to be that

The osxfs driver pretends that the files are owned by the USER that the container runs as
https://stackoverflow.com/questions/43097341/docker-on-macosx-does-not-translate-file-ownership-correctly-in-volumes

@galexrt
Copy link
Owner

galexrt commented Feb 2, 2018

@P4sca1 I see. The user starting the container was your "local" user (/UID) on your Mac then? if I understand correctly.
Do you want to add this information for Mac users to the README.md file?

@P4sca1
Copy link
Contributor Author

P4sca1 commented Feb 2, 2018

I'm going to make a pull request to update the README.md later this day.

@P4sca1 P4sca1 closed this as completed Feb 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants