Skip to content

Commit 1a5f478

Browse files
authored
Introduce how to configure cache when starting a Runner with Docker (#25077)
If a user starts a runner using a Docker image without making additional configurations, the [cache action](https://github.com/actions/cache) will not work properly. Therefore, add a section in the documentation that explains how to configure the cache correctly.
1 parent 62ac325 commit 1a5f478

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

docs/content/doc/usage/actions/act-runner.en-us.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,40 @@ It is because the act runner will run jobs in docker containers, so it needs to
172172
As mentioned, you can remove it if you want to run jobs in the host directly.
173173
To be clear, the "host" actually means the container which is running the act runner now, instead of the host machine.
174174

175+
### Configuring cache when starting a Runner using docker image
176+
177+
If you do not intend to use `actions/cache` in workflow, you can ignore this section.
178+
179+
If you use `actions/cache` without any additional configuration, it will return the following error:
180+
> Failed to restore: getCacheEntry failed: connect ETIMEDOUT <ip>:<port>
181+
182+
The error occurs because the runner container and job container are on different networks, so the job container cannot access the runner container.
183+
184+
Therefore, it is essential to configure the cache action to ensure its proper functioning. Follow these steps:
185+
186+
- 1.Obtain the LAN IP address of the host machine where the runner container is running.
187+
- 2.Find an available port number on the host machine where the runner container is running.
188+
- 3.Configure the following settings in the configuration file:
189+
190+
```yaml
191+
cache:
192+
enabled: true
193+
dir: ""
194+
# Use the LAN IP obtained in step 1
195+
host: "192.168.8.17"
196+
# Use the port number obtained in step 2
197+
port: 8088
198+
```
199+
200+
- 4.When starting the container, map the cache port to the host machine:
201+
202+
```bash
203+
docker run \
204+
--name gitea-docker-runner \
205+
-p 8088:8088 \
206+
-d gitea/act_runner:nightly
207+
```
208+
175209
### Labels
176210

177211
The labels of a runner are used to determine which jobs the runner can run, and how to run them.

docs/content/doc/usage/actions/act-runner.zh-cn.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,39 @@ docker run \
169169
如前所述,如果要在主机上直接运行Job,可以将其移除。
170170
需要明确的是,这里的 "主机" 实际上指的是当前运行 Act Runner的容器,而不是主机机器本身。
171171

172+
### 当您使用 Docker 镜像启动 Runner,如何配置 Cache
173+
174+
如果你不打算在工作流中使用 `actions/cache`,你可以忽略本段。
175+
176+
如果您在使用 `actions/cache` 时没有进行额外的配置,将会返回以下错误信息:
177+
> Failed to restore: getCacheEntry failed: connect ETIMEDOUT <ip>:<port>
178+
179+
这个错误的原因是 runner 容器和作业容器位于不同的网络中,因此作业容器无法访问 runner 容器。
180+
因此,配置 cache 动作以确保其正常运行是非常重要的。请按照以下步骤操作:
181+
182+
- 1.获取 Runner 容器所在主机的 LAN(本地局域网) IP 地址。
183+
- 2.获取一个 Runner 容器所在主机的空闲端口号。
184+
- 3.在配置文件中如下配置:
185+
186+
```yaml
187+
cache:
188+
enabled: true
189+
dir: ""
190+
# 使用步骤 1. 获取的 LAN IP
191+
host: "192.168.8.17"
192+
# 使用步骤 2. 获取的端口号
193+
port: 8088
194+
```
195+
196+
- 4.启动容器时, 将 Cache 端口映射至主机。
197+
198+
```bash
199+
docker run \
200+
--name gitea-docker-runner \
201+
-p 8088:8088 \
202+
-d gitea/act_runner:nightly
203+
```
204+
172205
### 标签
173206

174207
Runner的标签用于确定Runner可以运行哪些Job以及如何运行它们。

0 commit comments

Comments
 (0)