Docker Community Forums

Share and learn in the Docker community.

Can docker cp set user id and group?

(Steveflenniken) #1

When I use the docker cp command to copy a file to a running docker container the user id and group for the new file are set to root:root. Is there a way to copy and set the user id and group to some user, i.e. steve:steve using the cp command?

Currently I am attaching to the container and running chown on the new file but I would like to eliminate this step if possible. I tried:

docker cp .bashrc steve@hopeful_brahmagupta:/home/steve/

(Dvohra) #2

" Ownership is set to the user and primary group at the destination. For example, files copied to a container are created with UID:GID of the root user. Files copied to the local machine are created with the UID:GID of the user which invoked the docker cp command."