Home Explore Blog Models CI



docker

content/manuals/build/ci/github-actions/share-image-jobs.md
7f7ba93840c4c1b7f5fa353d2a6938a38a408710abf0b20c000000030000069b
---
title: Share built image between jobs with GitHub Actions
linkTitle: Share image between jobs
description: Share an image between runners without pushing to a registry
keywords: ci, github actions, gha, buildkit, buildx
---

As each job is isolated in its own runner, you can't use your built image
between jobs, except if you're using [self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners)
or [Docker Build Cloud](/build-cloud).
However, you can [pass data between jobs](https://docs.github.com/en/actions/using-workflows/storing-workflow-data-as-artifacts#passing-data-between-jobs-in-a-workflow)
in a workflow using the [actions/upload-artifact](https://github.com/actions/upload-artifact)
and [actions/download-artifact](https://github.com/actions/download-artifact)
actions:

```yaml
name: ci

on:
  push:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Build and export
        uses: docker/build-push-action@v6
        with:
          tags: myimage:latest
          outputs: type=docker,dest=${{ runner.temp }}/myimage.tar

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: myimage
          path: ${{ runner.temp }}/myimage.tar

  use:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Download artifact
        uses: actions/download-artifact@v4
        with:
          name: myimage
          path: ${{ runner.temp }}

      - name: Load image
        run: |
          docker load --input ${{ runner.temp }}/myimage.tar
          docker image ls -a
```

Chunks
a0e28097 (1st chunk of `content/manuals/build/ci/github-actions/share-image-jobs.md`)
Title: Sharing Docker Images Between Jobs in GitHub Actions
Summary
This document explains how to share a Docker image between jobs in a GitHub Actions workflow without using a registry. Since each job runs in an isolated runner, direct sharing isn't possible unless using self-hosted runners or Docker Build Cloud. The solution involves using `actions/upload-artifact` to save the image as an artifact in the first job and `actions/download-artifact` to retrieve it in subsequent jobs. The example YAML configuration demonstrates building and exporting the image in one job, uploading it as an artifact, then downloading and loading the image in another job.