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.

  • docker nodejs container cant connect mysql container
  • Increasing mysql max_connections to 1024 in a docker container
  • Generating dockerfile of a gradle java application
  • NodeJS in Docker - cannot access node_modules
  • Error: 403 Forbidden while pushing/pulling images to/from docker
  • Dockerized nodes of elasticsearch cluster in EC2, production environment
  • 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.

  • can't access docker container
  • Docker in the big picture for complete DevOps
  • Docker compose extra hosts with wildcards
  • How to allow HTTP requests to other docker containers with RSpec?
  • Editing a running docker container
  • run nginx in docker with another application
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.