GitHub Actions "Container action is only supported on Linux" in CI
Docker container actions run only on Linux runners. Using one in a job that runs on windows-latest or macos-latest fails because container actions are not supported on those platforms.
What this error means
A job on a Windows or macOS runner fails with "Error: Container action is only supported on Linux" when it reaches a Docker-based uses:.
Error: Container action is only supported on LinuxCommon causes
A Docker action on a non-Linux runner
The job's runs-on is Windows or macOS, but the action it calls is a container (Docker) action.
A matrix that includes non-Linux OSes
A matrix spreads the job across OSes, and the Linux-only container action fails on the non-Linux legs.
How to fix it
Run the Docker action on Linux
- Move the container action into a Linux job.
- Or replace it with a JavaScript/composite action that runs cross-platform.
- Re-run.
jobs:
scan:
runs-on: ubuntu-latest # container action needs Linux
steps:
- uses: docker://ghcr.io/acme/scanner:1Restrict the matrix leg with if
Gate the container-action step so it only runs on Linux legs of a multi-OS matrix.
- if: runner.os == 'Linux'
uses: docker://ghcr.io/acme/scanner:1How to prevent it
- Use container actions only in Linux jobs.
- Prefer JavaScript/composite actions for cross-platform steps.
- Guard Linux-only steps with
runner.os == 'Linux'.