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:$ $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:$': The requested URL returned error: 502

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

  • Unable to run rabbitmq using marathon mesos
  • Running Desktop Apps on Docker Containers on Windows 10
  • Raspberry pi zero Docker can't start container
  • Is it possible to create a docker image from Ubuntu ISO on Windows offline?
  • Cannot Compile the typescript in Docker
  • Node.js Running Hello World on Google Cloud Platform error deployment error
  • Any idea what could the problem be?

  • Destination location when using ADD command if <dest> is not provided
  • Where is the Docker daemon log on Ubuntu 14.04?
  • Build postgres docker container with initial schema
  • Can't access app deployed with docker and google cloud
  • Docker not response after long not using on windows 10 host
  • docker - cannot find aws credentials in container although they exist
  • 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.