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.

  • Docker maven plugin
  • Execute command on docker container from remote machine
  • can't connect to mysql docker when mount a directory
  • docker apache passenger: error cannot load such file bundler/setup (LoadError)
  • Meteor Spawn Error ENOENT
  • Importing .so file made with Cython results in ImportError: … undefined symbol
  • Any idea what could the problem be?

  • Have Concourse only build new docker containers on file diff not on commit
  • Docker 'WARNING: permission denied' on ubuntu
  • How to access my local system Postgres from Docker
  • Can I connect to host from docker container via 172.17.42.1?
  • Jupyter R crashes when plotting in docker container
  • docker registry fail to start up that prompts file not found which file does 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.