Reputation: 4868
What's the best way to build a custom container from a Dockerfile with custom configuration files? I want to do something like this:
FROM jboss/wildfly:latest
USER jboss
COPY configuration/standalone.xml /opt/jboss/wildfly/standalone/configuration/
But as a result the copied resource is owned by user 'root'. This is how the Docker documentation explains the COPY and ADD command. The USER switch is ignored.
So my question is: should I always run a chown command after copy/add new resources?
FROM jboss/wildfly:latest
USER jboss
COPY configuration/standalone.xml /opt/jboss/wildfly/standalone/configuration/
RUN chown -R jboss /opt/jboss/wildfly/standalone/configuration/
This looks a little bit clumsy to me?
Upvotes: 3
Views: 1494
Reputation: 1324576
That looks a little clumsy to me?
Yes, it is clumsy, and it was discussed in issue 7537, even patched in PR 9934.
But rejected.
You can look into PR 10775 and its COPY --user=
option, which was merged.
Upvotes: 3