Reproducible perl -i truncates file on host-mapped volume

Expected behavior

A perl in-place edit (-i) operation on a host-mapped volume leaves the file edited with expected content

Actual behavior

A perl in-place edit operation on a host-mapped volume leaves the file zero length

Information

OS X: version 10.11.4 (build: 15E65)
Docker.app: version v1.11.1-beta11
Running diagnostic tests:
[OK] docker-cli
[OK] Moby booted
[OK] driver.amd64-linux
[OK] vmnetd
[OK] osxfs
[OK] db
[OK] slirp
[OK] menubar
[OK] environment
[OK] Docker
[OK] VT-x
Docker logs are being collected into /tmp/20160517-182110.tar.gz
Most specific failure is: No error was detected
Your unique id is: EBE049CB-D50A-4B79-B6AD-EDD84E9D2059

Steps to reproduce the behavior

(linux host - correct)
$ mkdir /tmp/work
$ docker run --rm -it -v /tmp/work:/tmp/work ubuntu bash
container$ cd /tmp/work
container$ echo “one two” > test
container$ perl -i -p -e ‘s/two/three/g’ test
container$ cat test
one three

(mac os x 10.11.4 host - broken)
$ mkdir /tmp/work
$ docker run --rm -it -v /tmp/work:/tmp/work ubuntu bash
container$ cd /tmp/work
container$ echo “one two” > test
container$ perl -i -p -e ‘s/two/three/g’ test
container$ cat test
container$ ls -l test
-rw-r–r-- 1 root root 0 May 17 22:20 test

(Just confirmed with beta 12 as well)

Thanks for the bug report!
This has been opened as issue (#3219) on our tracker.

Docker for Windows is also affected but the file is deleted and not truncated.

See Perl -i truncates file on host-mapped volume