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

Owning the site output #5

Closed
wizhi opened this issue Nov 17, 2018 · 1 comment
Closed

Owning the site output #5

wizhi opened this issue Nov 17, 2018 · 1 comment

Comments

@wizhi
Copy link

wizhi commented Nov 17, 2018

Total Docker newbie here, hope you'll help me out.

Using this image with

$ docker run --rm -it -v "$SRC_PATH":/src -v "$TARGET_PATH":/target klakegg/hugo:0.51

I end up with a $TARGET_PATH folder owned by root, since Docker seems to write files to the shared volume on the host side, using the user/group id of the container user.

Trying to use the --user option, as I've seen suggested in a couple of other places, the container is unable to write to it's /target

$ docker run --rm --user "$(id -u):$(id -g)" -it -v "$SRC_PATH":/src -v "$TARGET_PATH":/target klakegg/hugo:0.51
Building sites … ERROR 2018/11/17 00:46:41 open /target/index.html: permission denied
ERROR 2018/11/17 00:46:41 mkdir /target/tags: permission denied
ERROR 2018/11/17 00:46:41 mkdir /target/tags: permission denied
ERROR 2018/11/17 00:46:41 mkdir /target/tags: permission denied
Total in 3 ms
Error: Error copying static files: chtimes /target/: operation not permitted

Of course this isn't the end of the world, since you could just chown the output, but I'm both lazy and curious as to how this might be worked around.

I did find jguyomard/docker-hugo, which kind of works around the issue by creating a user whoms home directory is set to the shared source folder, which just coincidentally has the same user id as most people using the image. This just seems like kind of a hack in my opinion.

What would be the right way to handle this whole thing?

@klakegg
Copy link
Owner

klakegg commented Dec 26, 2018

I think this is fixed (simply using --user only) as of images with Hugo 0.52 based upon Alpine. Please notify me if this doesn't work.

@klakegg klakegg closed this as completed Dec 26, 2018
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

2 participants