'How to reduce container image size when use no-root users?
In my another question why my docker image bigger than du -hd 1 .
I find when i use command like chmod or chown to make docker image,the size of image will be double, the dictory in docker layer save twice.
But i also find docker no-root user issue in bitnami websit why use no-root user image
Today,I want use user app in my container, but an error occur.no permission
But the image size will be bigger again.
What can i do?
In bitnami's image they use curl to download file,but i use ADD and COPY in Dockerfile.
Does ADD and COPY can change the user in dockerfile?
Solution 1:[1]
With COPY, there is a --chown flag:
COPY --chown=user src dest
This is described in the Dockerfile documentation.
The layered filesystem is copy-on-write at a file level, so any change to the file, including metadata like permissions and ownership, will result in a copy of the entire file to the new layer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BMitch |
