Couldn't resolve host within docker container and java process

I am facing an issue running a docker image based on alpine linux that runs a java process (GoCD server). The java process itself tries to run some code to clone a git repository locally however I am getting a Couldn't resolve host exception. I tried to manually clone the git repo from within the container using ‘git clone’ and had no issue.

In addition, I am able to ping the domain from within the docker container by running ping my-service-url.com with no issues and also from the host machine with the same result. It seems java has some difficulties resolving the name but I am not sure how to fix it.

  • Add windows folder in Dockerfile
  • spring-cloud-config in docker-compose https certificate not found
  • Installing docker into a VirtualBox VM running Ubuntu 12.04
  • dockercloud haproxy with more than one service on different ports
  • How to list images and their containers
  • How to provide parameter to docker run with “oc new-app” in OpenShift?
  • I tried creating a new image with RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf. I read in another question that would fix it but no luck. The whole Dockerfile looks like the following:

    FROM gocd/gocd-server:v17.5.0
    RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
    ADD json-config-plugin-0.2.jar /godata/plugins/external/json-config-plugin-0.2.jar
    ENTRYPOINT ["/docker-entrypoint.sh"]
    

    I am running on AWS ECS, ipv4 forwarding is set to 1 and network mode is bridge. I am running out of ideas.

  • Cannot increase size for docker container - Ubuntu 16.04
  • Mounting local directory in docker container on Windows fails silently
  • Elastic Search Multiple Publish Host
  • AWS Container Service - what is the logging best practice?
  • enable scripting within docker image
  • Set local network IP placeholder in docker-compose.yml
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.