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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Can I keep Docker images between Pipeline steps?

Hi, I am using the Pipeline to automate our builds and I've been struggling with the usage of steps and images. I am aware that I can keep generated files between steps using the artifacts option, but I can't seem to figure out how to keep docker images between steps.

My setup is currently like this:

pipelines:
custom:
dev:
- step:
  script:
- # docker build
- # push to GCR
- # push to AWS ECR

 What I want is something like:

pipelines:
custom:
dev:
- step:
  script:
- # docker build
artifacts:
- dist/**
- step:
script:
- # push to GCR
- step:
script:
- # push to AWS ECR 

Assume my credential configs are correct.

The problem is, tags created during the first step are not available on the next steps. So if I run docker build -t ${aws_ur}:${BITBUCKET_COMMIT} on the first step and then run docker push ${aws_url} on the last step the image will not exist (same for second step).

Am I doing something wrong (maybe the artifacts folder is wrong) or is there a way to do this?

Thanks in advance.

4 answers

For our project we were able to use docker save/load to share an image between steps.

- step:
  name: Build docker image
  script:
    - docker build -t "repo/imagename" .
    - docker save -output tmp-image.docker repo/imagename
  artifacts:
    - tmp-image.docker
- step:
  name: Deploy to Test
  deployment: test
  script:
   - docker load --input ./tmp-image.docker
   - docker images
   # repo/imagename should be available now

Syntax correction:

- docker save --output

Like # people like this

doesnt work anymore :(

worked for us, thanks

I figured it has to be the image size (limited to 1GB or not cacheable). I'd expect Bitbucket to cache all layers it can until 1GB is reached. For instance if I'm extending a PHP Docker image to install a few extensions and libs, I'd expect the base PHP Image to be cached if under 1GB. This is not the case it seems, it considers only the image we're building and mine easily exceeds 1GB since it also contains the codebase, tests and vendors after built.

Would be nice to see Bitbucket caching as many layers as possible before reaching 1GB for ANY image, not only the ones built (for most projects it's a lot more common the need to cache the BASE images we're extending).

Bump.. I'd love an answer in this one too :)

Bump. Need an answer on this, or pipelines are useless/dangerous for dockerception builds.

Suggest an answer

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

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,897 views 0 7
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