USER and COPY Docker command (basic)

Hello,

Just want to get some confirmation.
According to https://docs.docker.com/engine/reference/builder/#user (USER Docker file command documentation) and to https://docs.docker.com/engine/reference/builder/#copy (COPY Docker file command documentation), if, in a Dockerfile, I chain the 2 commands like below:

USER foo
COPY from to

This means that all files copied to “to” will belong to root user and not foo.

Is my understanding, right ? Could you confirm, please ?
Is this stuff subject to change in next Docker releases ?

Best Regards.

Hello,

Any answer to my questions ?

Best regards.

Hello,

Indeed, ADD doesn’t honour USER and the files copied will be owned by root.
You can see the discussion of the implementation of the feature here: https://github.com/moby/moby/pull/9934.
And the actual PR here: https://github.com/moby/moby/pull/10775

Last status is: “and I agree with you we should add that” :slight_smile: