question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sharing Docker containers between jobs in a workflow

See original GitHub issue

Is it possible to share Docker containers between jobs in a workflow? I tried building a container and setting load to true, but that does not make it available in the next jobb (tried running docker image ls, and the images I built did not appear

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

79reactions
crazy-maxcommented, Nov 15, 2020

@torkelrogstad

I don’t know the exact purpose or mechanics of this file, but it looks like the tag information is included, but not picked up when I’m loading. Do you know how to fix this?

Switch to outputs: type=docker,dest=/tmp/image.tar output:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v2
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      -
        name: Build and push
        uses: docker/build-push-action@v2
        with:
          context: .
          file: ./Dockerfile
          tags: myimage:latest
          outputs: type=docker,dest=/tmp/myimage.tar
      -
        name: Upload artifact
        uses: actions/upload-artifact@v2
        with:
          name: myimage
          path: /tmp/myimage.tar

  use:
    runs-on: ubuntu-latest
    needs: build
    steps:
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      -
        name: Download artifact
        uses: actions/download-artifact@v2
        with:
          name: myimage
          path: /tmp
      -
        name: Load Docker image
        run: |
          docker load --input /tmp/myimage.tar
          docker image ls -a
9reactions
crazy-maxcommented, Nov 10, 2020

@torkelrogstad

Docker containers between jobs in a workflow?

Each job is isolated in his own runner. That’s why you cannot see your image in another job. But you can pass data between jobs in a workflow. You can use the actions/upload-artifact and actions/download-artifact actions to do this.

Here is a quick example to upload an image as an artifact:

name: ci

on:
  push:
    branches: master

jobs:
  upload-artifact:
    runs-on: ubuntu-latest
    steps:
      -
        name: Checkout
        uses: actions/checkout@v2
      -
        name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      -
        name: Build and export
        uses: docker/build-push-action@v2
        with:
          context: .
          file: ./Dockerfile
          tags: name/app:latest
          outputs: type=oci,dest=/tmp/image.tar
      -
        name: Upload artifact
        uses: actions/upload-artifact@v2
        with:
          name: app
          path: /tmp/image.tar
Read more comments on GitHub >

github_iconTop Results From Across the Web

Build a Docker image in one job and use it in another job
For small images, you can achieve that by using workspaces to share the data among jobs. Build job. Build the Docker image
Read more >
Using Docker Containers In Jobs - GitHub Actions
Running multiple docker containers in a job. ... We can give the services as docker-images under the "services:" and they run as separate ......
Read more >
Speed Up Your CI With Docker (Github Actions) - Joël AZÉMAR
The purpose is to create a Docker image from our source code and run ... How to share your Docker image across your...
Read more >
How to share docker images between the jobs in github actions
Can you please share your GitHub Actions workflow files? – Harsh Mishra. May 20 at 9:04 · I am not sure if that...
Read more >
github actions share docker image between jobs
Share data between Docker based Actions in same Job I am trying to create my own Actions to build/ compile the files for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found