get "panic: EOF" when register runners run in a container
Overview
When using GitLab Runner in a container, the registration command fails.
Steps to reproduce
# docker-compose.yml
gitlab_runner:
env_file:
- ./.env
container_name: gitlab_runner
image: 'gitlab/gitlab-runner:latest'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /data/gitlab-runner/config:/etc/gitlab-runner
- /data/gitlab-runner/machine:/root/.docker/machine
restart: unless-stopped
execute
docker compose up -d gitlab_runner
# [+] Running 1/1
# ⠿ Container gitlab_runner Started
docker exec gitlab_runner gitlab-runner register
got error
Runtime platform arch=amd64 os=linux pid=21 revision=f761588f version=14.10.1
Running in system-mode.
Enter the GitLab instance URL (for example, https://gitlab.com/):
panic: EOF [recovered]
panic: EOF
goroutine 1 [running]:
main.main.func1()
/builds/gitlab-org/security/gitlab-runner/main.go:39 +0x5e
panic({0x1990c20, 0xc00011e0f0})
/usr/local/go/src/runtime/panic.go:1038 +0x215
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).askOnce(0xc000474280, {0x1cd6c2f, 0x41}, 0xc0007bf5f0, 0x0)
/builds/gitlab-org/security/gitlab-runner/commands/register.go:111 +0x2cd
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).ask(0xc000474280, {0x1c6271e, 0x3}, {0x1cd6c2f, 0xc0007bf6e0}, {0x0, 0x47f691, 0x30})
/builds/gitlab-org/security/gitlab-runner/commands/register.go:141 +0x170
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).askRunner(0xc000474280)
/builds/gitlab-org/security/gitlab-runner/commands/register.go:237 +0x57
gitlab.com/gitlab-org/gitlab-runner/commands.(*RegisterCommand).Execute(0xc000474280, 0xc0004cab00)
/builds/gitlab-org/security/gitlab-runner/commands/register.go:385 +0x192
github.com/urfave/cli.HandleAction({0x18ee360, 0xc00000cab0}, 0x8)
/go/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:492 +0x7b
github.com/urfave/cli.Command.Run({{0x1c68e2d, 0x8}, {0x0, 0x0}, {0x0, 0x0, 0x0}, {0x1c7ea28, 0x15}, {0x0, ...}, ...}, ...)
/go/pkg/mod/github.com/urfave/cli@v1.20.0/command.go:210 +0x8f8
github.com/urfave/cli.(*App).Run(0xc0000b96c0, {0xc00012c000, 0x2, 0x2})
/go/pkg/mod/github.com/urfave/cli@v1.20.0/app.go:255 +0x6ac
main.main()
/builds/gitlab-org/security/gitlab-runner/main.go:69 +0x2bc
Used GitLab Runner version
versions:
cat /etc/os-release
# NAME="Ubuntu"
# VERSION="20.04 LTS (Focal Fossa)"
# ID=ubuntu
# ID_LIKE=debian
# PRETTY_NAME="Ubuntu 20.04 LTS"
# VERSION_ID="20.04"
# HOME_URL="https://www.ubuntu.com/"
# SUPPORT_URL="https://help.ubuntu.com/"
# BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
# PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
# VERSION_CODENAME=focal
# UBUNTU_CODENAME=focal
docker -v
# Docker version 20.10.14, build a224086
docker compose version
# Docker Compose version v2.5.1
docker exec gitlab_runner gitlab-runner -v
# Version: 14.10.1
# Git revision: f761588f
# Git branch: 14-10-stable
# GO version: go1.17.7
# Built: 2022-05-02T16:08:41+0000
# OS/Arch: linux/amd64
Other GitLab Runner versions tested
- 16.4.0
- 17.3.1
Edited by Darren Eastman - OOO Back on 2026-01-05