Hacker News new | past | comments | ask | show | jobs | submit login

My latest story with Dockerfile:

my.tar contains files owned by user 0, I want them to be owned by nobody:

  USER nobody
  ADD --chown nobody:nobody my.tar /app
Damn, --chown does not work when untaring and doesn't fail either but the files end up being owned by root. Fine, I'll just chmod

  USER nobody
  ADD my.tar /app
  RUN chmod -R nobody:nobody /app
Now it fails (of course) because the files are owned by root and the command is ran as nobody.

While it all makes sense, I'm not sure why it's logic to have the ADD command always run as root and the others following the USER directive (yeah and I know, it's all my bad for using ADD rather then COPY)




> RUN chmod -R nobody:nobody /app

Did you know: RUNning chmod increases the size of the layer by the size of the file being chmodded[1]. Just some more of that magical secret sauce.

(With buildah you choose when to create a layer, so both the COPY and the chmod can be layered together)

[1]: https://blog.vamc19.dev/posts/dockerfile-copy-chmod/


Ah well, no I did not know, thanks :) in my case it's not too bad because I use kaniko's option to make a single layer of my changes, but good to know.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: