nektos/act - local github runner, how to reference local Platform (-P) image without needing docker.io

208 views Asked by At

How to run a local or non-docker image using nektos/act?

Nektos act by default attempts to login to docker.io to pull a remote image, is it possible to use a locally cached image?

1

There are 1 answers

0
Brian Horakh On

I ended up solving my problem, and so I'll post it with an answer.

The TLDR is --pull=false along with the -P platform flag will allow you to use a local image.

In my case I'm using a custom python image which was built locally called python-3.10:latest but you'd build your own local image using docker build . -f Dockerfile.python310 -t python-3.10:latest

To verify a local image use docker image ls, also you might need to make sure the architectures match (if the platform doesn't match, it won't find it, but it's probably fine if you're linux/amd64)

I'll try to work through the steps:

docker inspect --format='{{.Os}}/{{.Architecture}}' python-3.10:latest
linux/amd64

to debug:

gh act -s GITHUB_TOKEN="$(gh auth token)" -P python-3.10=localhost/python-3.10:latest -v --no-skip-checkout --pull=false

** make sure to use a very recent version of gh the github.com/cli/cli which supports auth token. You might need to replace your distro version which isn't updated as often!