Skip to content

Feature Request: Let docker cp respect .dockerignore files #40925

Open

Description

@pschichtel

Description

I have a use-case, where I want to create (but not start) a container on a remote docker host, then use docker cp to copy files over the network into the container and then start the container. Basically a Dockerfile with FROM, COPY and a RUN, but that does not actually produce a container.

While a COPY instruction in a Dockerfile respects .dockerignore files, the docker cp command does not support this, resulting in copying a lot of unnecessary files.

Describe the results you received:
Files that are matched by .dockerignore files are still being copied.

Describe the results you expected:
Files that are matched by .dockerignore files are not copied.

Additional information you deem important (e.g. issue happens only occasionally):
For backwards compatibility this should probably require a flag like --use-ignore or so.

Output of docker version:

Client:
 Version:           19.03.8-ce
 API version:       1.40
 Go version:        go1.14.1
 Git commit:        afacb8b7f0
 Built:             Thu Apr  2 00:04:36 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b7f0
  Built:            Wed Mar 11 01:24:28 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Activity

  1. margori commented on May 18, 2020

    @margori

    I confirm. I have same expectation docker cp should respect .dockerignore file

  2. added
    kind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shiny
    on May 27, 2020
  3. Madhur1997 commented on Jun 21, 2020

    @Madhur1997

    I would like to work on this

  4. itscaro commented on Sep 29, 2020

    @itscaro

    I have the same use-case. Building a new image to use COPY is less fit for my use-case.

  5. andregeert commented on Oct 27, 2020

    @andregeert

    My use case is in devops testing code inside a container. The environment takes a long time to build, I would like to copy the code directory at runtime, ignoring files in the .dockerignore list.

  6. kddsultan commented on Mar 7, 2024

    @kddsultan

    Does anyone know this is still the case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFunctionality or other elements that the project doesn't currently have. Features are new and shiny

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions