Skip to content

docker build fails with "archive/tar: write too long" when .dockerignore is a symlink #1059

@krwc

Description

@krwc
  • This is a bug report
  • This is a feature request
  • I searched existing issues before opening this one

Expected behavior

docker build should succeed no matter if .dockerignore is a symlink or not.

Actual behavior

Build fails with strange looking "archive/tar: write too long" error.

Steps to reproduce the behavior

Minimal example: docker_failure.zip

Imagine you have the following directory tree (as in the docker_failure.zip, note the .dockerignore is a symlink):

$ tree -a
.
├── Dockerfile
└── test
    ├── .dockerignore -> ignore
    └── ignore

1 directory, 3 files

When we enter test and try to build the image, we have an error:

$ cd test
$ docker build --no-cache --file ../Dockerfile .
Sending build context to Docker daemon     512B
error during connect: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.40/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=.dockerfile.fc23a238662d3ee404bd&labels=%7B%7D&memory=0&memswap=0&networkmode=default&nocache=1&rm=1&shmsize=0&target=&ulimits=null&version=1": archive/tar: write too long

I noticed two things:

  1. When .dockerignore is not a symlink, the build succeeds.
  2. When .dockerignore is/isn't a symlink, but the Dockerfile is in the same directory as working directory of docker build, the build succeeds.

Output of docker version:

Client:
 Version:           19.03.11-ce
 API version:       1.40
 Go version:        go1.14.3
 Git commit:        42e35e61f3
 Built:             Tue Jun  2 15:09:26 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          19.03.11-ce
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.14.3
  Git commit:       42e35e61f3
  Built:            Tue Jun  2 15:09:05 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.3.4.m
  GitCommit:        d76c121f76a5fc8a462dc64594aea72fe18e1178.m
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 65
  Running: 0
  Paused: 0
  Stopped: 65
 Images: 16
 Server Version: 19.03.11-ce
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d76c121f76a5fc8a462dc64594aea72fe18e1178.m
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.7.6-arch1-1
 Operating System: Arch Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.02GiB
 Name: coffeeriver
 ID: ABVL:KPYK:AWYL:KX5K:HONY:EI25:4ARU:U7Z4:P5PB:6RSU:EPQ3:RZXJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

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

It fails on physical machine. Didn't test anything else.

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