Build Docker image in one job and use in another job

Sometimes you may want to build a Docker image in one job, and use it in another job. The following steps can be used with smaller images to achieve that.


Build job

- Build the Docker image

- Save the image to a tar file

docker save -o <file path for generated tar file> <image name>

- Persist the image file to a workspace.


Downstream jobs

- Attache to the workflow workspace

- Load the Docker image from the workspace

docker load -i <path to image tar file>

- Enjoy - your image is available


Note: If your images are large (>~1GB) this will probably not be a great solution. You can try gzipping the images as well or consider strategies to reduce your image sizes



Was this article helpful?
5 out of 13 found this helpful



Please sign in to leave a comment.