Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bitbucket pipeline use locally built image from previous step

If I'd like to build a docker image in one pipeline step, then use it in a following step - how would I do that?

eg

default:
    - step:
        name: Build
        image: 
        script:
          - docker build -t imagename:local .
          - docker images
    - step:
        name: Deploy
        image: 
        script:
          - docker images

In this example, the image shows up in the first step, but not the second

like image 298
David Alsh Avatar asked Nov 17 '18 04:11

David Alsh


People also ask

Can I push Docker image to Bitbucket?

Bitbucket uses git under the hood and git is an excellent place to store text files, such as Dockerfile. It does support storing binary files but it is not a good match for Docker images.


1 Answers

You would use Docker Save/Load in conjunction with bitbucket artifacts.

Example:

- 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

Source: Link

like image 86
iceflow19 Avatar answered Oct 06 '22 01:10

iceflow19