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

This happens randomly, so sometimes it works sometimes I get this error.

  • how to import a file as a parameter in Docker?
  • Connection from Java UI container to couchDB container refuses
  • docker-compose.yml for elasticsearch and kibana
  • Create multiple Docker machines at once with docker-machine
  • Cannot attach debugger to a node.js application running inside a Docker container in host-mode
  • Docker swarm and published port not available
  • Any idea what could the problem be?

  • How to push the artifacts into docker image in Jenkins
  • Kubernetes doesn't pull from private Docker Registry
  • Deploying Docker Data Volumes
  • Can't see django site being run in docker container on localhost
  • Using nginx to reverse proxy to Docker services
  • Share and update docker data containers across containers
  • 2 Solutions collect form web for “The requested URL returned error: 502 when running git clone inside a Docker container”

    I also get random 502 errors from bitbucket since yesterday, so I’d assume bitbucket has currently some issues.

    The 502 http response means “Bad gateway”. So you have some kind of connection problem to the repository. I think the problem is not related to 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. 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 http_proxy http://x.x.x.x:xxxx
    ENV https_proxy https://x.x.x.x:xxxx
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.