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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,555,468
Community Members
 
Community Events
184
Community Groups

Dockerfile Copy Optional

Edited

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,
Theodora

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,
Theodora

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

Hi,

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,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events