AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-1108716

Andrej S's questions

Martin Hope
Andrej S
Asked: 2019-11-04 02:46:33 +0800 CST

Docker 容器在浏览器中可用,但在 curl 中不可用

  • 8

我有一个正在运行的 gitlab 容器。运行命令:

sudo docker run --detach \
  --hostname gitlab.domain.com \
  --publish 8888:80 --publish 2222:22 \
  --name gitlab \
  --restart always \
  --volume /home/apps/gitlab/config:/etc/gitlab \
  --volume /home/apps/gitlab/logs:/var/log/gitlab \
  --volume /home/apps/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest

gitlab 应用程序运行良好,可以通过输入http://192.168.1.141:8888从浏览器在本地网络上访问。(docker run 中定义的服务器内部 IP 和端口)

端口部分docker ps -a:

443/tcp, 0.0.0.0:2222->22/tcp, 0.0.0.0:8888->80/tcp

在服务器上打开端口:

~$ netstat -l | grep 8888
tcp6     0     0     [::]:8888     [::]:*     LISTEN

我添加192.168.1.141 gitlab.domain.com到/etc/hosts我的计算机上,并想在服务器端口 80 上运行的 apache 中设置一个代理。我的想法是仅通过输入来查看 gitlab 站点gitlab.domain.com。

我没有成功,所以我尝试从主机服务器卷曲容器。这些都不起作用: curl http://localhost:8888
curl http://192.168.1.141:8888

结果:

~$ curl http://localhost:8888 -v
*   Trying 127.0.0.1:8888...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8888 (#0)
> GET / HTTP/1.1
> Host: localhost:8888
> User-Agent: curl/7.66.0
> Accept: */*
> 

知道为什么会这样吗?如何从主机服务器连接到 gitlab 页面?

如果我curl 192.168.1.141:8888从我的电脑上做,它可以工作:

$ curl 192.168.1.141:8888 -v
* Rebuilt URL to: 192.168.1.141:8888/
*   Trying 192.168.1.141...
* TCP_NODELAY set
* Connected to 192.168.1.141 (192.168.1.141) port 8888 (#0)
> GET / HTTP/1.1
> Host: 192.168.1.141:8888
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 302 Found
< Server: nginx
< Date: Sun, 03 Nov 2019 16:27:53 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 105
< Connection: keep-alive
< Cache-Control: no-cache
< Location: http://192.168.1.141:8888/users/sign_in
< Referrer-Policy: strict-origin-when-cross-origin
< Set-Cookie: experimentation_subject_id=ImQyMThkOWI4LWM2MjQtNGM5ZS1hOTZiLTc4YTFhN2U3YjhmNSI%3D--a9d45810de1608210d337df71cbad8c0ac10de16; path=/; expires=Thu, 03 Nov 2039 16:27:53 -0000
< X-Content-Type-Options: nosniff
< X-Download-Options: noopen
< X-Frame-Options: DENY
< X-Permitted-Cross-Domain-Policies: none
< X-Request-Id: LnCSv7rcW6a
< X-Runtime: 0.010182
< X-Ua-Compatible: IE=edge
< X-Xss-Protection: 1; mode=block
< Strict-Transport-Security: max-age=31536000
< Referrer-Policy: strict-origin-when-cross-origin
< 
* Connection #0 to host 192.168.1.141 left intact
<html><body>You are being <a href="http://192.168.1.141:8888/users/sign_in">redirected</a>.</body></html>
docker localhost
  • 1 个回答
  • 1453 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve