moby: cp: preserving permissions for '/bar': Invalid argument

Description

After upgrading Docker for Mac to 1.13.0-rc7-beta37 (15013) from rc6, my build fails with an error from cp about preserving permissions when using -rp.

Steps to reproduce the issue:

  1. Create this Dockerfile:
FROM ubuntu:16.04
RUN mkdir /foo
RUN cp -rp /foo /bar
  1. docker build .

Describe the results you received:

Step 1/3 : FROM ubuntu:16.04
 ---> bd3d4369aebc
Step 2/3 : RUN mkdir /foo
 ---> Running in c05ee1ef5f1c
 ---> 923b0c9d9e85
Removing intermediate container c05ee1ef5f1c
Step 3/3 : RUN cp -rp /foo /bar
 ---> Running in 86cc22d02c92
cp: preserving permissions for '/bar': Invalid argument
The command '/bin/sh -c cp -rp /foo /bar' returned a non-zero code: 1

Describe the results you expected:

From Docker 1.12.3 on a different machine (this also worked with 1.13.0-rc5 and rc6):

Step 1 : FROM ubuntu:16.04
 ---> 104bec311bcd
Step 2 : RUN mkdir /foo
 ---> Running in 799277a89b9c
 ---> d806168b8014
Removing intermediate container 799277a89b9c
Step 3 : RUN cp -rp /foo /bar
 ---> Running in 57ea33a071d3
 ---> 0700a4b77202
Removing intermediate container 57ea33a071d3
Successfully built 0700a4b77202

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

This error appears after upgrading from 1.13.0-rc6 to rc7.

Output of docker version:

Client:
 Version:      1.13.0-rc7
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   48a9e53
 Built:        Fri Jan 13 21:41:57 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      1.13.0-rc7
 API version:  1.25 (minimum version 1.12)
 Go version:   go1.7.3
 Git commit:   48a9e53
 Built:        Fri Jan 13 21:41:57 2017
 OS/Arch:      linux/amd64
 Experimental: true

Output of docker info:

Containers: 99
 Running: 18
 Paused: 0
 Stopped: 81
Images: 594
Server Version: 1.13.0-rc7
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 696
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 03e5862ec0d8d3b3f750e19fca3ee367e13c090e
runc version: 2f7393a47307a16f8cee44a37b262e8b81021e3e
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.3-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 2.934 GiB
Name: moby
ID: XKZB:LGXI:4HPS:6TPF:ZWNZ:JZAW:KG65:LFIP:SBM5:QMXF:23MQ:A6US
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 147
 Goroutines: 130
 System Time: 2017-01-18T13:34:10.833485639Z
 EventsListeners: 1
Username: wojas
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

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

Using Docker for Mac

Version 1.13.0-rc7-beta37 (15013)
Channel: Beta
f2c3d3454f

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 33 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I narrowed the issue down to cp -r --preserve=mode /foo /bar, probably in the copy_acl() call in coreutils. It only happens on container filesystems, not in volumes. Maybe a bug in aufs?

Some context: this error happens when running the OpenResty configure script.

My temporary hacky workaround:

RUN echo '#!/bin/sh\n\
shift 1; /bin/cp -r "$@"' > /usr/local/bin/cp && chmod 755 /usr/local/bin/cp
RUN ./configure -j2
RUN rm -f /usr/local/bin/cp

sfjro@users.sourceforge.net:

Justin Cormack:

@sfjro I can confirm that the patch you posted to the mailing list does = fix this issue.

Thanx. The patch will be included in next aufs release.

The patch was refined and merged into today’s aufs release. The newer is better and recommended.

J. R. Okajima

Beta 39 which was released today has the fix. It will be in the next stable, which should be next week.

The default is now overlay2 if you reset, you can override in the advanced config by adding the json config.

On 25 Jan 2017 9:48 p.m., “Joe Swantek” notifications@github.com wrote:

@justincormack https://github.com/justincormack would you happen to know the Docker beta version that this was fix was released in? Also, when this will arrive in the next Docker stable release?

I experienced this same issue and am confused how my Docker daemon was configured to aufs when I didn’t specifically change anything when I upgraded my stable version last week. Thoughts?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/docker/docker/issues/30245#issuecomment-275243180, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdcPL3uRZUpeYbTZeXBwgGPNguPUIf8ks5rV8MhgaJpZM4Lm48g .

@sfjro I can confirm that the patch you posted to the mailing list does fix this issue.

@wojas we will ship this with the next beta (due tomorrow) .