In my case the java application was failing with java.net.UnknownHostException
when running in docker. The reason was that I used --network=none
docker flag (getting ip/hostname via dhcp and pipework). In this case, docker does not add automatically to /etc/hosts
entry like
127.0.0.1 15e326aecf84
And getCanonicalHostName()
Java function threw this exception.
Possible solutions:
- add hostname entry to
/etc/hosts
file viadocker run
parameter--hostname=your-hostname.com
- switch to docker-managed network configuration