Skip to content
This repository has been archived by the owner on Feb 3, 2019. It is now read-only.

Docker image: problems with permissions on OS X #10

Closed
ravicious opened this issue Mar 7, 2016 · 11 comments
Closed

Docker image: problems with permissions on OS X #10

ravicious opened this issue Mar 7, 2016 · 11 comments

Comments

@ravicious
Copy link
Contributor

First I want to say that I tried many different ways to cross-compile Rust code to RasPi 3B and this one seems to be the most promising so far.

I'm on OS X 10.11.3, Docker 1.10.2, Rust 1.7.0. I have successfully built the Docker image, but I ran into some permission problems as I tried to cross-compile my project.

If I run cargo build on host environment and then try to run the image, I get the following error:

$ docker run -v /Users/rav/Projects/rust/guessing_game:/home/cross/project rust-17-pi-cross build 
*** Extracting target dependencies ***

*** Cross compiling project ***
could not remove build directory

To learn more, run the command again with --verbose.

If I run cargo clean first, then I get this error:

$ docker run -v /Users/rav/Projects/rust/guessing_game:/home/cross/project rust-17-pi-cross build --verbose
*** Extracting target dependencies ***

*** Cross compiling project ***
    Updating registry `https://github.com/rust-lang/crates.io-index`
couldn't prepare build directories

Caused by:
  Permission denied (os error 13)

I looked for ways to solve it on Docker level, but none of them helped (like adding :z to the end of the volume path). Also, I believe most of them assume the image is running SELinux, while this Dockerfile uses Debian.

Pinging @schnupperboy, as from the issue tracker I see he's the one who added Docker support, so maybe he knows something that I don't. 😉

@Ogeon
Copy link
Owner

Ogeon commented Mar 7, 2016

I'm afraid I can't tell, off the top of my head, what the problem may be, but I'm thinking that it would be a good idea to set up some Travis tests for this, if it's solved.

@ravicious
Copy link
Contributor Author

I just ran into "Web Development with Docker on Mac OS X":

If you want to access files within the /Users share from your Docker container, then you should do so as a user with uid 1000, otherwise you will likely have permissions errors.

I added RUN usermod -u 1000 cross to the Dockerfile right after the line that creates the group and the user. Currently the image is building, I'll let you know if it helps.

@Ogeon
Copy link
Owner

Ogeon commented Mar 7, 2016

That would be great.

ravicious added a commit to ravicious/rust-on-raspberry-pi that referenced this issue Mar 7, 2016
Fixes permission errors on OS X:

  The “/Users” folder will be automatically mounted in the VM,
  and the mount will be owned by a user named “docker” with
  a uid number of 1000.

  If you want to access files within the /Users share from your
  Docker container, then you should do so as a user with uid 1000,
  otherwise you will likely have permissions errors.

https://medium.com/@brentkearney/docker-on-mac-os-x-9793ac024e94

Fixes Ogeon#10.
@ravicious
Copy link
Contributor Author

It solved my problem! I feel so relieved now, thank you for maintaining this repo! I was able to compile and then run the program on Raspi after changing the uid. The submitted PR #11 fixes that.

@Ogeon
Copy link
Owner

Ogeon commented Mar 8, 2016

Nice! I was just about to merge it. It's also nice to know that it's possible to get it working on OS X. Was there anything special you had to do to get it working? Something that might be useful to add to the guide?

@schnupperboy
Copy link

@ravicious Thanks for investigating this issue and glad to hear that it works now. I added a comment to your PR.

@Ogeon I will have a look later this week on how to set up a Travis test for the Docker build with a Linux host OS. Also, I will open a new issue for this.

But i'm afraid that there is no way you can set up a Travis test with a OS X host environment since Docker requires running a Linux virtual machine as a workaround on OS X. AFAIK Travis CI simply does not support this.

@Ogeon
Copy link
Owner

Ogeon commented Mar 8, 2016

I will have a look later this week on how to set up a Travis test for the Docker build with a Linux host OS. Also, I will open a new issue for this.

That would be fantastic. I'm just afraid that the build process may be too long for Travis. It's still worth a try, so I'll go ahead and enable Travis for this repo (edit: done).

But i'm afraid that there is no way you can set up a Travis test with a OS X host environment since Docker requires running a Linux virtual machine as a workaround on OS X. AFAIK Travis CI simply does not support this.

Looks like that's the case, unfortunately. Still, it's better to have any tests, than none.

@ravicious
Copy link
Contributor Author

@schnupperboy Cool, I updated the PR!

@Ogeon

Was there anything special you had to do to get it working? Something that might be useful to add to the guide?

The process was pretty straightforward and I didn't have to do anything special other than installing the Docker Toolbox and following its "Getting started" guide.

@Ogeon
Copy link
Owner

Ogeon commented Mar 8, 2016

It may be good to at least mention that the toolbox is necessary if it's not part of what's usually installed with Docker.

@Ogeon Ogeon closed this as completed in e8e5b25 Mar 8, 2016
@ravicious
Copy link
Contributor Author

I don't think the whole toolbox is necessary, it was just the first "official" way to install Docker I found.

Thanks for merging both PRs!

@Ogeon
Copy link
Owner

Ogeon commented Mar 8, 2016

I don't think the whole toolbox is necessary, it was just the first "official" way to install Docker I found.

I guess people will figure it out, then.

Thanks for merging both PRs!

Thanks for helping 😄

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

3 participants