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.
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.