Why are the permissions of the file created by docker exec and the file created by entering the container different?

Viewed 21

I created a file in the container using:

docker exec -u root container_1 touch /working/flag.tmp

Enter the container and check the permissions of the file. The result is:

rw-r-----

Then I use the same command in the container to create the file and check the file permissions:

rw-r--r--

It is worth noting that the file permissions I created using the 'touch' command in the host are the same as those created in the container. The results above make me wonder, so I have two questions:

  1. How to make the file created by docker exec have the same permissions as the file created in the container?
  2. What causes this problem of inconsistency of permissions, and how to avoid it as much as possible?

Thanks for your reply.

0 Answers
Related