简体   繁体   English

在 Docker 容器内运行 git clone 时,请求的 URL 返回错误:502

[英]The requested URL returned error: 502 when running git clone inside a Docker container

I have a simple bash script git clone https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/danechitoaie/open-pipelines-test1.git $BUILD_DIR that I run in a Docker container and the problem is that sometimes git clone fails with following error message fatal: unable to access 'https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/danechitoaie/open-pipelines-test1.git/': The requested URL returned error: 502我有一个简单的 bash 脚本git clone https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/danechitoaie/open-pipelines-test1.git $BUILD_DIR我在 Docker 容器中运行,问题是有时 git克隆失败并显示以下错误消息fatal: unable to access 'https://x-token-auth:$REPOSITORY_OAUTH_ACCESS_TOKEN@bitbucket.org/danechitoaie/open-pipelines-test1.git/': The requested URL returned error: 502

This happens randomly, so sometimes it works sometimes I get this error.这是随机发生的,所以有时它会起作用,有时我会收到此错误。

Any idea what could the problem be?知道问题是什么吗?

The 502 http response means "Bad gateway". 502 http 响应意味着“Bad gateway”。 So you have some kind of connection problem to the repository.所以你有某种与存储库的连接问题。 I think the problem is not related to docker.我认为问题与docker无关。 Probably on the host machine containing your Docker containers you'll have the same behavior if you try the git clone to the repository.可能在包含 Docker 容器的主机上,如果您尝试将 git clone 到存储库,您将具有相同的行为。 Test it if you can.如果可以,请测试一下。

You said it happens randomly.你说它是随机发生的。 Are you behind a proxy or something similar?你是代理还是类似的东西? That issue happens sometimes under that proxy scenario.该问题有时会在该代理方案下发生。 If that is your case, remember to put ENV var in your Dockerfiles with the proxy settings:如果是这种情况,请记住使用代理设置将 ENV var 放入 Dockerfiles 中:

ENV http_proxy http://x.x.x.x:xxxx
ENV https_proxy https://x.x.x.x:xxxx

自昨天以来,我还从 bitbucket 中收到随机 502 错误,因此我认为 bitbucket 目前存在一些问题。

I got same issue in my company while clone a repository from GitHub, that may caused by your host machine network proxy configuration.从 GitHub 克隆存储库时,我在我的公司遇到了同样的问题,这可能是由您的主机网络代理配置引起的。

I don't know your network environment, but in my company, if you want visit Internet, you must config a proxy.我不知道你的网络环境,但在我公司,如果你想访问互联网,你必须配置一个代理。

I edited .gitconfig by vim ~/.gitconfig , change to another http proxy server我通过vim ~/.gitconfig编辑了vim ~/.gitconfig ,更改为另一个 http 代理服务器

........
[http]
        proxy = http://username:password@anotherproxy.mycompany.com:8080
[https]
        proxy = https://username:password@anotherproxy.mycompany.com:8080
        sslVerify = false
.....

and run git clone https://github.com/somesuer/someproject.git , it works并运行git clone https://github.com/somesuer/someproject.git ,它的工作原理

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git 克隆错误:请求的URL返回错误:403 - Git Clone Error: The requested URL returned error: 403 git错误:RPC失败; HTTP 502 curl 22 请求的URL返回错误:502 Proxy Error - git error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 Proxy Error Git 推送错误:RPC 失败; HTTP 502 curl 22 请求的 URL 返回错误:502 - Git push error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 Git 推送 RPC 失败; HTTP 502 curl 22 请求的 URL 返回错误:502 网关错误 - Git push RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 Bad Gateway 请求的 URL 返回错误 502,企业? - The requested URL returned error 502, corporate? git 错误:RPC 失败; HTTP 502 curl 22 请求的 URL 返回错误:502 致命:远端意外挂断 - git error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 fatal: the remote end hung up unexpectedly 尝试使用nginx设置智能http git服务器:“请求的URL返回错误:502” - Trying to setup smart http git server with nginx: “The requested URL returned error: 502” Phabricator clone请求的URL返回错误:500 - Phabricator clone The requested URL returned error: 500 Git & Github: can't push or clone via SSH or Https, the requested URL returned error 400 - Git & Github: can't push or clone via SSH or Https, the requested URL returned error 400 来自docker容器内的git clone项目 - git clone project from inside docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM