0

I have a the following docker file:

FROM my-reg:7678/py:v11
copy . /app/
# more commands...

I want to copy the content of . without 2 sub-folders: .git and data

I can't use .dockerignore because some docker files use the folder data and some are not.

(the docker files which use data folder use the copy . /app/ command)

The solution here: COPY with docker but with exclusion is not fit for me: I want to let the docker file to decide to use or not .dockerignore. and It seems not efficient to copy the folder and after it to remove some sub folders.

  • Is there a way to give copy command sub folders to ignore ?
  • Is there a way to instruct the docker file to use .dockerignore file or to ignore it ?
Boom
  • 1,145
  • 18
  • 44
  • Does this answer your question? [COPY with docker but with exclusion](https://stackoverflow.com/questions/43747776/copy-with-docker-but-with-exclusion) – Paolo Oct 04 '20 at 17:43
  • no. as I wrote I want to ket the docker file to decide to use or not .dockerignore. and It seems not efficient to copy the folder and after it to remove some sub folders. – Boom Oct 04 '20 at 18:31

1 Answers1

0

About your questions:

Is there a way to give copy command sub folders to ignore ?

  • I don't think there is another way to do this if you don't want to delete the copied folders.

Is there a way to instruct the docker file to use .dockerignore file or to ignore it ?

  • See this post, you can define multiple .dockerignore configs. So you could have one Dockerfile that does not ignore the data folder and one that does.
code-gorilla
  • 2,231
  • 1
  • 6
  • 21