我完全知道在同一台机器上设置GitLab和GitLab Runner是一种不好的做法,但我这样做只是为了测试目的。我在Ubuntu OS上通过Docker安装了GitLab和GitLab Runner。
管道给出以下错误:
x1c 0d1x的数据
正如你所看到的,runner不能从repository克隆。到目前为止,我所做的是:
这是docker-compose文件
version: '3'
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
hostname: 'localhost:180'
container_name: 'gitlab'
restart: unless-stopped
networks:
- gitlab-network
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://localhost:180'
ports:
- '180:80'
- '1443:443'
- '122:22'
- '1587:587'
volumes:
- 'gitlab_config:/etc/gitlab'
- 'gitlab_logs:/var/log/gitlab'
- 'gitlab_data:/var/opt/gitlab'
shm_size: '6gb'
gitlab-runner:
container_name: 'gitlab-runner'
image: 'gitlab/gitlab-runner:latest'
networks:
- gitlab-network
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./config:/etc/gitlab-runner
restart: unless-stopped
volumes:
gitlab_config : {}
gitlab_logs : {}
gitlab_data: {}
networks:
gitlab-network:
driver: bridge
字符串
这是/etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "my-runner"
url = "http://gitlab/"
id = 3
token = "glrt-rg-noV98QitS65raRQzk"
token_obtained_at = 2023-12-05T10:33:20Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
tls_verify = false
image = "alpine:latest"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
network_mtu = 0
型
我的理解
localhost在GitLab Runner容器中的含义是不同的,它指向容器本身,而不是主机。所以我尝试用不同的方式设置extra_host
,如下所示:
extra_hosts = ["localhost:gitlab"]
:它报告错误,gitlab
不是有效的URLextra_hosts = ["localhost:IP_ADDRESS_HOST_MACHINE"]
:不工作extra_hosts = ["localhost:IP_ADDRESS_GITLAB_CONTAINER"]
:不工作
我也在两个服务中设置了network_mode: "host"
,但没有工作。
我一直在努力解决这个问题大约一个星期了,我已经尝试了各种方法,但我还没有得出任何结论。
1条答案
按热度按时间rpppsulh1#
你应该可以通过docker网络访问gitlab。只需相应地设置
clone_url
参数。字符串