Use this file to discover all available pages before exploring further.
In this guide, you’ll learn how to leverage GitHub Actions’ matrix strategy to run the same job across multiple environments without duplicating YAML. By the end, you’ll be able to execute Docker commands on various OS runners and image combinations in parallel.
Run docker run hello-worldUnable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-world...Hello from Docker!This message shows that your installation appears to be working correctly.
Imagine scaling this to more OS versions or Docker images. You’d end up copying and pasting nearly identical job definitions:
jobs: deploy-on-ubuntu: runs-on: ubuntu-latest steps: - name: Echo Docker Details run: docker info - name: Run Image run: docker run hello-world deploy-on-windows: runs-on: windows-latest steps: - name: Echo Docker Details run: docker info - name: Run Image run: docker run hello-world # ...more duplicates for other OS or images
Maintaining this becomes a headache as you add environments.
Let’s refactor our example to run two Docker images (hello-world and alpine) across three OS environments (ubuntu-latest, ubuntu-20.04, windows-latest):
In some cases, certain image/OS combinations may not be supported. For example, alpine has no Windows manifest, so that job fails:
Run docker run alpineUnable to find image 'alpine:latest' locallylatest: Pulling from library/alpinedocker: no matching manifest for windows/amd64 in the manifest list entries.See 'docker run --help'.Error: Process completed with exit code 1
By default, a failure in one matrix job cancels the rest and marks the workflow as failed. Use continue-on-error: true on a step or job-level conditionals if you want to proceed despite errors.