gpt4 book ai didi

docker - 无法向在官方 Docker 容器中运行的 gitlab 发出请求

转载 作者:行者123 更新时间:2023-12-02 19:35:44 26 4
gpt4 key购买 nike

我正在尝试使用给出的指令从 Docker(gitlab/gitlab-ce,最新)容器运行 gitlab here .

docker 版本

Docker version 1.12.4, build 1564f02

我先跑
docker run --detach --hostname <myIP> --publish 8000:443--publish 8001:80 --publish 8002:22 --name gitlab --restart always --volume /docker/app/gitlab/config:/etc/gitlab --volume /docker/app/gitlab/logs:/var/log/gitlab --volume /docker/app/gitlab/data:/var/opt/gitlab gitlab/gitlab-ce:latest

然后我编辑了容器的 /etc/gitlab/gitlab.rb设置
external_url 'http://<myIP>:8001'
gitlab_rails['gitlab_shell_ssh_port'] = 8002

然后我重新启动了容器
docker restart gitlab

现在。

当我尝试连接到 <myIP>:8001 时我得到一个 (110) Connection timed out .

当我从 Docker 容器的主机尝试时,我得到
xxx@xxx:~$ curl localhost:8001
curl: (56) Recv failure: Connection reset by peer

日志(只是结束)
==> /var/log/gitlab/gitlab-workhorse/current <==
2017-07-26_14:53:41.50465 localhost:8001 @ - - [2017-07-26 14:53:41.223110228 +0000 UTC] "GET /help HTTP/1.1" 200 33923 "" "curl/7.53.0" 0.281484

==> /var/log/gitlab/nginx/gitlab_access.log <==
127.0.0.1 - - [26/Jul/2017:14:53:41 +0000] "GET /help HTTP/1.1" 200 33967 "-" "curl/7.53.0"

==> /var/log/gitlab/gitlab-monitor/current <==
2017-07-26_14:53:47.27460 ::1 - - [26/Jul/2017:14:53:47 UTC] "GET /sidekiq HTTP/1.1" 200 3399
2017-07-26_14:53:47.27464 - -> /sidekiq
2017-07-26_14:53:49.22004 ::1 - - [26/Jul/2017:14:53:49 UTC] "GET /database HTTP/1.1" 200 42025
2017-07-26_14:53:49.22007 - -> /database
2017-07-26_14:53:51.48866 ::1 - - [26/Jul/2017:14:53:51 UTC] "GET /process HTTP/1.1" 200 7132
2017-07-26_14:53:51.48873 - -> /process

==> /var/log/gitlab/gitlab-rails/production.log <==
Started GET "/-/metrics" for 127.0.0.1 at 2017-07-26 14:53:55 +0000
Processing by MetricsController#index as HTML
Filter chain halted as :validate_prometheus_metrics rendered or redirected
Completed 404 Not Found in 1ms (Views: 0.7ms | ActiveRecord: 0.0ms)

docker
xxx@xxx:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
67e013741b6d gitlab/gitlab-ce:latest "/assets/wrapper" 2 hours ago Up About an hour (healthy) 0.0.0.0:8002->22/tcp, 0.0.0.0:8001->80/tcp, 0.0.0.0:8000->443/tcp gitlab

网络统计
xxx@xxx:~$ netstat --listen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 0 *:2020 *:* LISTEN
tcp 0 0 *:git *:* LISTEN
tcp 0 0 *:43918 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
tcp6 0 0 [::]:8000 [::]:* LISTEN
tcp6 0 0 [::]:8001 [::]:* LISTEN
tcp6 0 0 [::]:8002 [::]:* LISTEN
tcp6 0 0 [::]:2020 [::]:* LISTEN
tcp6 0 0 [::]:git [::]:* LISTEN
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:43730 [::]:* LISTEN
udp 0 0 *:54041 *:*
udp 0 0 *:sunrpc *:*
udp 0 0 *:snmp *:*
udp 0 0 *:958 *:*
udp 0 0 localhost:969 *:*
udp 0 0 *:37620 *:*
udp6 0 0 [::]:54611 [::]:*
udp6 0 0 [::]:sunrpc [::]:*
udp6 0 0 localhost:snmp [::]:*
udp6 0 0 [::]:958 [::]:*

我找不到问题所在。有人可以帮忙吗?

最佳答案

这是一个 docker-compose.yml这对我来说很好用

version: '2'
services:
gitlab:
image: gitlab/gitlab-ce:latest
ports:
- "8002:22"
- "8000:8000"
- "8001:443"
environment:
- "GITLAB_OMNIBUS_CONFIG=external_url 'http://192.168.33.100:8000/'"
volumes:
- ./config:/etc/gitlab
- ./logs:/var/log/gitlab
- ./data:/var/opt/gitlab

问题是当您将外部 url 配置为 <MyIP>:8000 时容器内的监听端口也更新为 8000。在您的情况下,您正在映射端口 800080你应该映射 80008000只要

阅读以下网址以获取相同的详细信息

https://docs.gitlab.com/omnibus/settings/nginx.html#setting-the-nginx-listen-port

如果您需要覆盖此端口,则可以在 gitlab.rb 中执行此操作
nginx['listen_port'] = 8081

我更喜欢使用 docker-compose 启动 Gitlab文件而不是命令,因为它很容易配置、启动、重启 gitlab

关于docker - 无法向在官方 Docker 容器中运行的 gitlab 发出请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45329240/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com