Home > Software design >  How to reduce container image size when use no-root users?
How to reduce container image size when use no-root users?

Time:03-23

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?

CodePudding user response:

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.

  • Related