Docker application deployment on Cloud Foundry fails due to no route to host error
Docker application deployment on Cloud Foundry fails due to no route to host error.
Symptoms
When you deploy a Docker application on Cloud Foundry, an error similar to the following message is displayed:
Creating container
Successfully created container
Staging...
Staging process started ...
Failed to talk to docker registry: Get https://registry-1.docker.io/v2/: dial tcp 54.152.209.167:443: getsockopt: no route to host
Failed to talk to docker registry: Get http://registry-1.docker.io/v2/: dial tcp 54.152.209.167:80: getsockopt: no route to host
Staging process failed: Exit trace for group:
builder exited with error: failed to fetch metadata from [cloudfoundry/lattice-app] with tag [latest] and insecure registries [] due to Get http://registry-1.docker.io/v2/: dial tcp 54.152.209.167:80: getsockopt: no route to host
Exit status 2
Staging Failed: Exited with status 2
Destroying container
Successfully destroyed container
FAILED
Error restarting application: StagingError
In this message, the failed application is trying to access the Internet to download content. If you require the use of an HTTP proxy to reach the Internet, you must configure your application to use the proxy.
Resolving the problem
-
Log in to Cloud Foundry:
cf login -
Change to the organization and space where the application is deployed:
cf target -o <org> -s <space> -
Push the Docker application but do not start it:
cf push myApp --docker-image --no-start <docker container image> -
Set the HTTP proxy variables for the application. For example, if your proxy is
http://myproxy.com:3128, run the following command:cf set-env myApp https_proxy "http://myproxy.com:3128" cf set-env myApp http_proxy "http://myproxy.com:3128" -
Start the application. Run the following command:
cf restart myApp