Can I use the same docker container in pipeline diferent steps?

Nagore García March 2, 2021

In my pipeline first step I build a docker container which I want to use in my following steps. Is this possible?

Thank you

1 answer

0 votes
Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 2, 2021

@Nagore Garcíayes, sure, you can do it, just ensure you put building-pushing container step before actions where you use this image

Nagore García March 5, 2021

In this case how do I do it?

pipelines: 

default:

- step:

name: initialize

script:

- docker build -f Dockerfile.build -t app .

- docker run --rm -t -d --name app app

- step:

name: clean

script: - docker stop app

Halyna Berezovska
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 16, 2021

@Nagore García 

Basically, you may want to build and push to some registry image firstly.

In this case you can use it as in this documentation

https://support.atlassian.com/bitbucket-cloud/docs/use-docker-images-as-build-environments/

or as a service - for service definition have a look at https://support.atlassian.com/bitbucket-cloud/docs/databases-and-service-containers/ doc.

 

But if you don't want to push, you may want to use docker save/docker load command and pass image archive created by docker save through artifacts.

 

I guess, this is non-standard solution, for best practice it would be better to push image (e.g., dockerhub allows to store several private repos for free).

 

Regards, Galyna

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events