Skip to content
Latchkey

How to Share a Docker Image as an Artifact in GitHub Actions

docker save writes an image to a tar you can upload as an artifact, then docker load restores it in another job.

When you do not want to push to a registry, docker save the image to a tar, upload it with actions/upload-artifact@v4, and docker load it in a downstream job.

Steps

  • Build the image and docker save it to a tar file.
  • Upload the tar as an artifact.
  • In the next job, download it and docker load the tar.

Workflow

.github/workflows/ci.yml
jobs:
  build-image:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: docker build -t myapp:ci .
      - run: docker save myapp:ci -o image.tar
      - uses: actions/upload-artifact@v4
        with:
          name: docker-image
          path: image.tar
  scan-image:
    needs: build-image
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          name: docker-image
      - run: docker load -i image.tar
      - run: docker run --rm myapp:ci node --version

Gotchas

  • Saved image tars are large; use compression-level: 0 since layers are already compressed.
  • For anything shared long-term or across repos, a registry push beats a saved-image artifact.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →