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

我试图从Docker(gitlab / gitlab-ce,latest)容器使用这里给出的指令运行gitlab。

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 ps

 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 

用netstat

 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 

问题是当你configuration外部URL为<MyIP>:8000 ,容器内的监听端口也更新为8000.在你的情况下,你将8000端口映射到80端口,你应该只映射80008000

请阅读下面的url,了解相同的细节

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

如果你需要覆盖这个端口,那么你可以在gitlab.rb做到这gitlab.rb

 nginx['listen_port'] = 8081 

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