Skip to content

uid and gid mismatch when using 'ADD --chown' in Dockerfile #36349

@KamilKopaczyk

Description

@KamilKopaczyk

Description

Using ADD --chown results in files being owned by some other uid/gid than provided in chown.

Steps to reproduce the issue:

  1. Use ADD with --chown flag in Dockerfile: ADD --chown=www-data:www-data build_artifact.tar.gz /var/www
  2. RUN chown www-data:www-data /var/www
  3. Build image from this Dockerfile
  4. Create and run container from built image
  5. Run ls -la /var/www/

Describe the results you received:

Files and directories owned by uid 1001 and gid 1002. Both uid and gid is not assigned to any user in container and host machine. What's interesting, /var/www (.) is owned by www-data:www-data.

drwxr-xr-x  1 www-data www-data      6 Feb 19 10:32 .
drwxr-xr-x  1 root     root         16 Jan 22 09:40 ..
drwxr-xr-x  3     1001     1002   4096 Feb 12 11:35 .ebextensions
-rw-r--r--  1     1001     1002    722 Feb 19 10:31 .env

Describe the results you expected:

Files and directories are owned by provider www-data user:

drwxr-xr-x  1 www-data www-data      6 Feb 19 10:32 .
drwxr-xr-x  1 root     root         16 Jan 22 09:40 ..
drwxr-xr-x  3     www-data www-data   4096 Feb 12 11:35 .ebextensions
-rw-r--r--  1     www-data www-data    722 Feb 19 10:31 .env

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      17.05.0-ce
 API version:  1.29
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:04:27 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.05.0-ce
 API version:  1.29 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   89658be
 Built:        Thu May  4 22:04:27 2017
 OS/Arch:      linux/amd64
 Experimental: false

Applies to 17.09.1-ce (both server and client) too

Output of docker info:

Containers: 130
 Running: 82
 Paused: 0
 Stopped: 48
Images: 320
Server Version: 17.05.0-ce
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: false
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Kernel Version: 4.9.0-0.bpo.3-amd64
Operating System: Debian GNU/Linux 8 (jessie)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 11.73GiB
Name: test
ID: 6WMS:QUD3:QRMU:WG46:3OQ3:ZINF:56XV:6PWA:N7N6:J2NF:VAVE:F3W5
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
 provider=generic
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: overlay2: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior.
         Reformat the filesystem with ftype=1 to enable d_type support.
         Running without d_type support will not be supported in future releases.
WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):

Debian 8.10
Linux test 4.9.0-0.bpo.3-amd64 #1 SMP Debian 4.9.30-2+deb9u2~bpo8+1 (2017-06-27) x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions