hashicorp / packer-plugin-docker

Packer plugin for Docker Builder
https://www.packer.io/docs/builders/docker
Mozilla Public License 2.0
30 stars 26 forks source link

file provisioner changes permissions of parent directory when uploading directory #16

Open ghost opened 3 years ago

ghost commented 3 years ago

This issue was originally opened by @GeorgFleig as hashicorp/packer#5955. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.


When I use the file provisioner to upload files into a Docker container in a folder not owned by root, the permissions of the parent folder of the destination are changed.

Example: before copy

    docker: drwxr-xr-x 2 build build 4096 Feb 28 14:57 .
    docker: drwxr-xr-x 1 root  root  4096 Feb 28 14:57 ..
    docker: -rw-r--r-- 1 build build  220 May 15  2017 .bash_logout
    docker: -rw-r--r-- 1 build build 3526 May 15  2017 .bashrc
    docker: -rw-r--r-- 1 build build  675 May 15  2017 .profile

after copy

    docker: drwxr-xr-x 2 root build 4096 Feb 28 14:57 .
    docker: drwxr-xr-x 1 root root  4096 Feb 28 14:57 ..
    docker: -rw-r--r-- 1 root build  220 May 15  2017 .bash_logout
    docker: -rw-r--r-- 1 root build 3526 May 15  2017 .bashrc
    docker: -rw-r--r-- 1 root build  675 May 15  2017 .profile
    docker: -rw-r--r-- 1 root build  538 Feb 28 10:20 file1.json
    docker: -rwxr-xr-x 1 root build 2704 Feb 28 12:23 file1.json

The owner of the parent folder /home/build is changed from build to root.

This happens when I copy a folder or the contents of a folder into that target. When I copy only a single file, the new file is owned by root:root as expected while all other permissions stay untouched.