[GH-ISSUE #1291] failing to run K3s action, file not found #700

Closed
opened 2026-03-01 21:45:38 +03:00 by kerem · 4 comments
Owner

Originally created by @sgandon on GitHub (Aug 5, 2022).
Original GitHub issue: https://github.com/nektos/act/issues/1291

Bug report info

act --bug-report                                                                                                                                                    ─╯
act version:            0.2.30
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 10
Docker host:            DOCKER_HOST environment variable is unset/empty.
Sockets found:
	/var/run/docker.sock
Config files:
	/Users/sgandon/.actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.18.4
	Module path:           command-line-arguments
	Main version:
	Main path:
	Main checksum:
	Build settings:
		-compiler:            gc
		-ldflags:             -X main.version=0.2.30
		CGO_ENABLED:          1
		CGO_CFLAGS:
		CGO_CPPFLAGS:
		CGO_CXXFLAGS:
		CGO_LDFLAGS:
		GOARCH:               arm64
		GOOS:                 darwin
Docker Engine:
	Engine version:        20.10.17
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Docker Desktop
	OS type:               linux
	OS version:
	OS arch:               aarch64
	OS kernel:             5.10.104-linuxkit
	OS CPU:                5
	OS memory:             7951 MB
	Security options:
		name=seccomp,profile=default
		name=cgroupns

Command used with act

act --container-architecture linux/amd64 -W run-k3s.yml

Describe issue

fails to run the k3s action that is supposed to be spawning a light K8s cluster

No response

Workflow content

name: Run k3s

on: [push]

jobs:
  run_k3s:
    runs-on: ubuntu-latest
    steps:

      - name: Install kubectl
        uses: azure/setup-kubectl@v3

      - name: Install K3s (kubernetes cluster)
        uses: debianmaster/actions-k3s@master
        id: k3s
        with:
          version: 'latest'

Relevant log output

[Run k3s/run_k3s]   🐳  docker exec cmd=[node /var/run/act/actions/debianmaster-actions-k3s@master/dist/index.js] user= workdir=
| storing kubeconfig here /tmp/output/kubeconfig-latest.yaml!
| [command]/usr/bin/docker run -d --privileged --name=k3s-latest --expose=6443 -e K3S_KUBECONFIG_OUTPUT=/tmp/output/kubeconfig-latest.yaml -e K3S_KUBECONFIG_MODE=666 -v /tmp/output:/tmp/output -p 6443:6443 -p 80:80 -p 443:443 -p 8080:8080 rancher/k3s:latest server
| f83ae6731f0a40743a012ddb8760f0d1733bb0c546ca0e60ad7e5779b8874f1a
|
[Run k3s/run_k3s]   ⚙  ::set-output:: kubeconfig=/tmp/output/kubeconfig-latest.yaml
| [command]/opt/hostedtoolcache/kubectl/1.24.3/x64/kubectl get nodes --no-headers -oname
| W0805 09:48:22.491215      67 loader.go:221] Config not found: /tmp/output/kubeconfig-latest.yaml
| The connection to the server localhost:8080 was refused - did you specify the right host or port?
[Run k3s/run_k3s]   ❗  ::error::The process '/opt/hostedtoolcache/kubectl/1.24.3/x64/kubectl' failed with exit code 1
[Run k3s/run_k3s]   ❌  Failure - Main Install K3s (kubernetes cluster)

Additional information

when I look into my local machine filesystem I find the file /tmp/output/kubeconfig-latest.yaml, it does exists but I guess it is probably not in the act container and that may be the failing part ?
Is there a way to specify mounted volumes on the act container ?

Originally created by @sgandon on GitHub (Aug 5, 2022). Original GitHub issue: https://github.com/nektos/act/issues/1291 ### Bug report info ```plain text act --bug-report ─╯ act version: 0.2.30 GOOS: darwin GOARCH: arm64 NumCPU: 10 Docker host: DOCKER_HOST environment variable is unset/empty. Sockets found: /var/run/docker.sock Config files: /Users/sgandon/.actrc: -P ubuntu-latest=catthehacker/ubuntu:act-latest -P ubuntu-22.04=catthehacker/ubuntu:act-22.04 -P ubuntu-20.04=catthehacker/ubuntu:act-20.04 -P ubuntu-18.04=catthehacker/ubuntu:act-18.04 Build info: Go version: go1.18.4 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -compiler: gc -ldflags: -X main.version=0.2.30 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: arm64 GOOS: darwin Docker Engine: Engine version: 20.10.17 Engine runtime: runc Cgroup version: 2 Cgroup driver: cgroupfs Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Docker Desktop OS type: linux OS version: OS arch: aarch64 OS kernel: 5.10.104-linuxkit OS CPU: 5 OS memory: 7951 MB Security options: name=seccomp,profile=default name=cgroupns ``` ### Command used with act ```sh act --container-architecture linux/amd64 -W run-k3s.yml ``` ### Describe issue fails to run the k3s action that is supposed to be spawning a light K8s cluster ### Link to GitHub repository _No response_ ### Workflow content ```yml name: Run k3s on: [push] jobs: run_k3s: runs-on: ubuntu-latest steps: - name: Install kubectl uses: azure/setup-kubectl@v3 - name: Install K3s (kubernetes cluster) uses: debianmaster/actions-k3s@master id: k3s with: version: 'latest' ``` ### Relevant log output ```sh [Run k3s/run_k3s] 🐳 docker exec cmd=[node /var/run/act/actions/debianmaster-actions-k3s@master/dist/index.js] user= workdir= | storing kubeconfig here /tmp/output/kubeconfig-latest.yaml! | [command]/usr/bin/docker run -d --privileged --name=k3s-latest --expose=6443 -e K3S_KUBECONFIG_OUTPUT=/tmp/output/kubeconfig-latest.yaml -e K3S_KUBECONFIG_MODE=666 -v /tmp/output:/tmp/output -p 6443:6443 -p 80:80 -p 443:443 -p 8080:8080 rancher/k3s:latest server | f83ae6731f0a40743a012ddb8760f0d1733bb0c546ca0e60ad7e5779b8874f1a | [Run k3s/run_k3s] ⚙ ::set-output:: kubeconfig=/tmp/output/kubeconfig-latest.yaml | [command]/opt/hostedtoolcache/kubectl/1.24.3/x64/kubectl get nodes --no-headers -oname | W0805 09:48:22.491215 67 loader.go:221] Config not found: /tmp/output/kubeconfig-latest.yaml | The connection to the server localhost:8080 was refused - did you specify the right host or port? [Run k3s/run_k3s] ❗ ::error::The process '/opt/hostedtoolcache/kubectl/1.24.3/x64/kubectl' failed with exit code 1 [Run k3s/run_k3s] ❌ Failure - Main Install K3s (kubernetes cluster) ``` ### Additional information when I look into my local machine filesystem I find the file `/tmp/output/kubeconfig-latest.yaml`, it does exists but I guess it is probably not in the act container and that may be the failing part ? Is there a way to specify mounted volumes on the act container ?
kerem 2026-03-01 21:45:38 +03:00
Author
Owner

@ChristopherHX commented on GitHub (Aug 5, 2022):

Your problem is you get docker in docker, but expecting docker inside a VM.

Is there a way to specify mounted volumes on the act container ?

You can, but that not enough to solve your problem
See here https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes, you can use the docker image name you use for ubuntu-latest in act.

The next problem is that you cannot reach localhost:8080 from the container.

Finally you probably want to throw away the idea of running all steps in docker, see https://github.com/nektos/act/pull/1293#issue-1330191414. Then act could run all commands directly on your system, see https://github.com/nektos/act/actions/runs/2806014990 for a experimental prebuild.

<!-- gh-comment-id:1206866261 --> @ChristopherHX commented on GitHub (Aug 5, 2022): Your problem is you get docker in docker, but expecting docker inside a VM. > Is there a way to specify mounted volumes on the act container ? You can, but that not enough to solve your problem See here https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes, you can use the docker image name you use for ubuntu-latest in act. The next problem is that you cannot reach localhost:8080 from the container. Finally you probably want to throw away the idea of running all steps in docker, see https://github.com/nektos/act/pull/1293#issue-1330191414. Then act could run all commands directly on your system, see https://github.com/nektos/act/actions/runs/2806014990 for a experimental prebuild.
Author
Owner

@sgandon commented on GitHub (Aug 10, 2022):

thanks a lot for your answer.
I have tried to use the native version of act but run into a few problems that I manage to fix by fideling with environment variables mostly.
About docker-in-docker this seems to be something that could be implemented in act I suppose, could'nt it ?
I fact we are using self hosted runners on Kubernetes and we have docker-in-dcoker enabled runners which make the k3s action work like a charm.
Do you think we should create an issue for this feature or maybe there is already one ?

<!-- gh-comment-id:1210300507 --> @sgandon commented on GitHub (Aug 10, 2022): thanks a lot for your answer. I have tried to use the native version of act but run into a few problems that I manage to fix by fideling with environment variables mostly. About docker-in-docker this seems to be something that could be implemented in act I suppose, could'nt it ? I fact we are using self hosted runners on Kubernetes and we have docker-in-dcoker enabled runners which make the k3s action work like a charm. Do you think we should create an issue for this feature or maybe there is already one ?
Author
Owner

@ChristopherHX commented on GitHub (Aug 10, 2022):

Ok I misunderstood, docker-in-docker means running a nested docker daemon inside a container. Act only offers a bind mount of the host docker socket, which causes this problem. E.g. act is just doing docker run -v /var/run/docker.sock:/var/run/docker.sock, which leads to your problem.

Feel free to create a feature request for Docker-in-Docker, but this also requires custom docker images including the dind patch like docker:dind.

With the experimental non docker act, you may or may not archive this like,

containerid=$(docker run --privileged -d -v /path/to/act:/usr/local/bin/act -v "$PWD:$PWD" -w "$PWD" docker:dind)
# You need to wait for dockerd to start
# Run act
docker exec -it "$containerid" act -P self-hosted=-self-hosted -P ubuntu-latest=-self-hosted
# Remove the container
docker rm --force "$containerid"

If you have access to the container images you use on kubernetes with self-hosted runners, you can also run the native version of act manually inside of the container if you know how to start the container without Kubernetes.

<!-- gh-comment-id:1210468059 --> @ChristopherHX commented on GitHub (Aug 10, 2022): Ok I misunderstood, docker-in-docker means running a nested docker daemon inside a container. Act only offers a bind mount of the host docker socket, which causes this problem. E.g. act is just doing `docker run -v /var/run/docker.sock:/var/run/docker.sock`, which leads to your problem. Feel free to create a feature request for Docker-in-Docker, but this also requires custom docker images including the dind patch like docker:dind. With the experimental non docker act, you may or may not archive this like, ```bash containerid=$(docker run --privileged -d -v /path/to/act:/usr/local/bin/act -v "$PWD:$PWD" -w "$PWD" docker:dind) # You need to wait for dockerd to start # Run act docker exec -it "$containerid" act -P self-hosted=-self-hosted -P ubuntu-latest=-self-hosted # Remove the container docker rm --force "$containerid" ``` If you have access to the container images you use on kubernetes with self-hosted runners, you can also run the native version of act manually inside of the container if you know how to start the container without Kubernetes.
Author
Owner

@github-actions[bot] commented on GitHub (Sep 10, 2022):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:1242569125 --> @github-actions[bot] commented on GitHub (Sep 10, 2022): Issue is stale and will be closed in 14 days unless there is new activity
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#700
No description provided.