我正在尝试在容器站的 QNAP(基于 TS-451 x86,固件 4.2.0)上运行 gocd docker 容器( https://hub.docker.com/r/gocd/gocd-server/ )。
容器没有启动并用 java.net.UnknownHostException 炸毁:
May 21 20:21:28 gocd-server-1 syslog-ng[16]: syslog-ng starting up; version='3.5.3'
using default settings from /etc/default/go-server
ERROR: Failed to start Go server. Please check the logs.
java.lang.RuntimeException: gocd-server-1: gocd-server-1
at com.thoughtworks.go.util.ExceptionUtils.bomb(ExceptionUtils.java:36)
at com.thoughtworks.go.server.util.GoSslSocketConnector.getHostname(GoSslSocketConnector.java:102)
at com.thoughtworks.go.server.util.GoSslSocketConnector.storeX509Certificate(GoSslSocketConnector.java:92)
at com.thoughtworks.go.server.util.GoSslSocketConnector.sslConnector(GoSslSocketConnector.java:56)
at com.thoughtworks.go.server.util.GoSslSocketConnector.<init>(GoSslSocketConnector.java:51)
at com.thoughtworks.go.server.Jetty9Server.sslConnector(Jetty9Server.java:133)
at com.thoughtworks.go.server.Jetty9Server.configure(Jetty9Server.java:76)
at com.thoughtworks.go.server.GoServer.configureServer(GoServer.java:84)
at com.thoughtworks.go.server.GoServer.startServer(GoServer.java:70)
at com.thoughtworks.go.server.GoServer.go(GoServer.java:63)
at com.thoughtworks.go.server.util.GoLauncher.main(GoLauncher.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.simontuffs.onejar.Boot.run(Boot.java:306)
at com.simontuffs.onejar.Boot.main(Boot.java:159)
Caused by: java.net.UnknownHostException: gocd-server-1: gocd-server-1
at java.net.InetAddress.getLocalHost(InetAddress.java:1496)
at com.thoughtworks.go.server.util.GoSslSocketConnector.getHostname(GoSslSocketConnector.java:100)
... 15 more
Caused by: java.net.UnknownHostException: gocd-server-1
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
我检查了容器内的 /etc/hosts - 它包括正确的主机映射:10.0.3.2 gocd-server-1
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.3.2 gocd-server-1
hostname resovles correctly:
root@gocd-server-1:/tmp# hostname
gocd-server-1
容器映像很好 - 我在 vagrant Ubuntu vm 上运行了完全相同的 gocd docker 容器,没有任何问题
所以这个问题在某种程度上与 QNAP Linux(这似乎是 Ubuntu 4.1.2)有关
[~] # cat /proc/version Linux version 3.12.6 (root@NasX86-12) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)) #1 SMP Fri Mar 11 02:20: 16 CST 2016)
任何想法如何解决 java.net.UnknownHostException 异常?