Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Dockerfile Copy Optional


In my pipeline I am using service docker. I am trying to Copy a file if it exists, but the engine version , Copy needs at least one file to exist otherwise it fails. I have tried with global expressions, resource/*.txt, resource/*.tx[t] resource/*.?xt. it doesn't work but in docker desktop it works normal to date. but in my pipeline the same instruction returns this error no error is returned: no source files were specified

1 answer

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 24, 2023

Hi @rsalazari and welcome to the community.

If the resource/ directory contains only text files (when it's not empty) and you want to copy all of them, you can try the following command instead

COPY resource/ /path-to-destination-dir/

I have tested this in Pipelines and the command doesn't fail if the resource/ directory is empty.

If the resource/ directory may contain files other than .txt ones that you don't want to copy, I would suggest copying the txt files first in a separate directory before you build the Docker image, so you can then use a COPY command similar to what I have shared.

You mentioned that locally you haven't had any issues. Could you perhaps let me know the output of docker version on this machine, and the OS + version of the machine?

Kind regards,

Thank you very much for the answer in that in my resources folder there are more than one sensitive file and I do not want to copy all of them, only one specific one, of course, as long as the file exists. This is because the idea is to make a dockerfile Generic - my projects contain the same instructions with the differential that some do not have that file and also not copy

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 28, 2023

Hi @rsalazari,

Thank you for your reply and the additional details about your use case. Does my suggestion work for you or are you still having any issues?

Kind regards,

It works, but since I have files that should not be copied for security reasons, copying them is not feasible yet. I would think it would be great if the COPY instruction would not fail even if it does not find a resource, it would just throw a waring.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 03, 2023


I understand what you are saying; this is the only workaround I can think of at the moment, which would work if the files you want to copy are saved in a separate folder from the ones you don't want to copy.

With Docker Desktop this indeed does not fail. However, I tried installing the latest version of Docker Engine on a Linux machine, and the copy fails as well (with resource/*.txt and resource/*) if there are no files in the directory. It doesn't look like the issue is specific to Pipelines and the version of Docker in Pipelines; it looks like this is something that works with Docker Desktop but not with Docker Engine.

Kind regards,

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events