Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker? Running the course-in-a-box on my (local) box #146

Open
Newman5 opened this issue Nov 20, 2023 · 4 comments
Open

Docker? Running the course-in-a-box on my (local) box #146

Newman5 opened this issue Nov 20, 2023 · 4 comments

Comments

@Newman5
Copy link

Newman5 commented Nov 20, 2023

Hey Gang! I know that this hasn't been updated recently. But here is my issue.

I'd like to create a tutorial (that could become a course) using the course-in-a-box. I figure I'd like to get it running locally.

When following the instructions for Local from the readme,
I run this code:

nsl@LAPTOP: ~/ad-ipsum/p2pu-LMS-site$ docker run -i -t --rm -u 1000:1000 -p 4000:4000 -v `pwd`:/opt/app -v `pwd`/.bundler/:/opt/bundler -e BUNDLE_PATH=~/opt/bundler -w /opt/app ruby:2.7 bash -c "bundle install && bundle exec jekyll serve --watch -H 0.0.0.0"

I get this error:
/ is not writable.
Bundler will use /tmp/bundler20231120-7-lprlp17' as your home directory temporarily. There was an error while trying to write to /home/nsl/opt/bundler/ruby/2.7.0`. It is likely that you need to grant write
permissions for that path.

Any help would be great!

@dirkcuys
Copy link
Member

Hi @Newman5

I think docker is creating the .bundler directory with root permissions, but the image itself runs as user 1000, which then doesn't have access to the directory.

sudo chown 1000:1000 .bundler/

should sort the problem out.

@Newman5
Copy link
Author

Newman5 commented Nov 22, 2023

Hey Dirk! Thanks for the help. And, that chown command makes sense to me. But it didn't work. Here is a what I get:
image

Any help would be appreciated. Thanks!

@pvanheus
Copy link

This is how I run it:

docker run -i -t --rm -u 1000:1000 \
    -p 4000:4000 -v $(pwd):/opt/app \
    -v $(pwd)/.bundler/:/opt/bundler \
    -e BUNDLE_PATH=/opt/bundler \
    -w /opt/app ruby:2.7 bash \
    -c "bundle install && bundle exec jekyll serve --watch -H 0.0.0.0"

This maps the bundler path to a local folder called .bundler and solves the ownership issue.

@pvanheus
Copy link

pvanheus commented Mar 11, 2024

Apologies, there is an error in my example above... I think it only worked because on that machine I was user 1000. This works, without any chowns etc.

if [ ! -d .bundler ] ; then mkdir .bundler ; fi
 
docker run -i -t --rm -u $(id -u):$(id -g) \
    -p 4000:4000 -v $(pwd):/opt/app \
    -v $(pwd)/.bundler/:/opt/bundler \
    -e BUNDLE_PATH=/opt/bundler \
    -w /opt/app ruby:2.7 bash \
    -c "bundle install && bundle exec jekyll serve --watch -H 0.0.0.0"

@Newman5: on your command line you had BUNDLE_PATH=~/opt/bundler which will expand to $HOME/opt/bundler which in your case is /home/nsl/opt/bundler - thus the permission denied. You need to ensure that BUNDLE_PATH and the location that you map to $(pwd)/.bundler lines up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants