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.

  • Multiple SymmetricDS instances at same host
  • Volumes not binding with the docker remote API
  • Cannot publish: Visual Studio 2015 Tools for Docker
  • How to enable the Docker Remote API on Windows
  • Communication between docker containers in differente networks
  • Mount git branches in a container
  • Any idea what could the problem be?

  • docker compose, vagrant and insecure Repository
  • docker-compose restart inverval
  • on Docker
  • How do you set up an elastic search cluster with multiple master nodes in docker compose?
  • Openshift doesn't copy docker container files to persistence volume
  • How can I diagnose issue with Oracle Data Pump import failing with error 1089
  • 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.