Skip to content

docker cp archive/tar error with filenames greater than 100 characters #484

@mkozell

Description

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

Expected behavior

Using docker cp should copy files and directories from container to host with filenames greater than 100 characters for Docker version 18.06.1-ce and higher.

Actual behavior

Using docker cp container_name:/etc/resolv.conf a_very_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_long_filename_that_is_101_characters in 18.03.1-ce works but results in the error below on 18.06.1-ce and higher.

archive/tar: cannot encode header: Format specifies USTAR; and USTAR cannot encode Name="a_very_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_long_filename_that_is_101_characters"

Steps to reproduce the behavior

Output of docker version:

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  
Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5

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

I was able to reproduce the issue in Docker 18.06.1-ce and 18.09.0-ce but not in Docker 18.03.1-ce. The commands below can reproduce the issue. I reproduced the issue using CentOS 7.5 and Amazon Linux 2 hosts. I then used Vagrant to confirm the issue locally.

docker pull centos:7
docker run -d -i --name docker_test centos:7
docker cp docker_test:/etc/resolv.conf a_very_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_long_filename_that_is_100_characters
docker cp docker_test:/etc/resolv.conf a_very_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_long_filename_that_is_101_characters

It appears a change to Golang v1.10 may have changed the default archive/tar format to USTAR which has a 100 character Linkname limit.

https://golang.org/doc/go1.10#archive/tar
https://golang.org/pkg/archive/tar/#Format

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions