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

 

Resources: https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository

Was this article helpful?
2 out of 4 found this helpful

Comments

0 comments

Please sign in to leave a comment.