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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Building and Pushing Docker Images

(question moved from the Bitbucket section)

We have a simple app we're trying to build in much the same vein as this article:

https://confluence.atlassian.com/bitbucket/build-and-push-a-docker-image-to-a-container-registry-884351903.html

We have everything the app needs except the repo on a private image in GCR.  We've set up a pipelines yml as close to the example as we can get, but when it gets to the docker build portion, it throws this error:

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /opt/atlassian/pipelines/agent/build/Dockerfile: no such file or directory

What we want to happen here is for Pipelines to take our base image (image A), clone the repo into a folder on that image, and then push the resulting image back up as a production-ready image (image B, which is just image A with our repo in it)

I'd like to confirm my understanding of how this would occur:

- the Pipelines Docker build environment is pulling our image and (as the build setup process) creating a container from that image and cloning the repo into that container in  $BITBUCKET_CLONE_DIR

- the build environment (not our container) is then building (or committing?) the container that now has our repo and pushing it up 

options: docker: true
image: name: us.gcr.io/our-project/ourImage:buildTag
username: _json_key
password: '$GCLOUD_API_KEY'
pipelines:
branches:
Production:
-
step:
name: Build Production Image
deployment: production
caches: - docker
script:
- docker build -t us.gcr.io/$GCLOUD_PROJECT/$IMAGE_NAME:$IMAGE_TAG .
- docker push us.gcr.io/$GCLOUD_PROJECT/$IMAGE_NAME:$IMAGE_TAG

I think what I'm confused about is the Dockerfile: am I meant to supply a Dockerfile in that path on my image? Or is docker build not even what I'm after here since I just want to commit the environment as I have it?

Thanks for your help!

2 answers

1 vote

Hi Samuel,

What is the location of your Dockerfile? The error is indicating that Docker can't find a Dockerfile in the current directory.

If you need to specific the path of the Dockerfile, you can use the `-f` flag

docker build -f <path_to_docker_file> -t us.gcr.io/$GCLOUD_PROJECT/$IMAGE_NAME:$IMAGE_TAG . 

Thanks,

Phil

Hi Phil,

I know that I can supply a Dockerfile, but the example (in the link in my post) didn't reference doing that -- I figured out from the error that I could just add the folder /opt/atlassian/pipelines/agent/build/ to my build image and put a Dockerfile in it, but the help article didn't say anything about that.

So while on the one hand it's obvious that you need a Dockerfile for docker build to do anything -- the Atlassian page says "just do this and Pipelines will build your app" while running their code exactly will produce the error. I wasn't sure when I wrote this post what all was going on in Pipelines (since it has its own Docker environment) and at first it seemed like they were injecting a Dockerfile based on Pipelines environment variables. That made less sense as I got into it.

Thanks for your assistance!

Sam

Any one got solution?

 

Do we need add our own Docker file ?

 

Thanks

Murali

sure you need to create and commit Dockerfile, as only you knows how image should be build.

Bitbucket only a scheduler who executes predefined script, nothing more.

Any one got solution?

 

Do we need add our own Docker file ?

Yes, you need to have your own Dockerfile. You just need to run docker commands in the same way you would locally.

I do have a Dockerfile and I have the same issue:

 

unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /opt/atlassian/pipelines/agent/build/Dockerfile

You either have no Dockerfile in the current directory or your Dockerfile is called something else. You can specify the docker file with the -f option.

 

$ docker build -f Dockerfile.debug .

For more info

https://docs.docker.com/engine/reference/commandline/build/ 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,057 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you