I think I need some help, when trying to setup doc...
# lucee
g
I think I need some help, when trying to setup docker on an Alpine host server based install it appears like I get some sort of Inetaddress error trying to pull its hostname from inside the docker commandbox lucee 5.2.x image (also alpine based). I think the issue is on the host side though, because this works fine from a Ubuntu server running Docker.
Copy code
createObject("java", "java.net.InetAddress").getLocalHost().getHostName()
I found a stackoverflow page that suggested trying this, but this info was already in that file.
Copy code
RUN echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf
Looks like even after I changed the code to run hostname via cfexecute that it does not like that either and errors with "Error invoking external process" w/ a stracktrace that is useful as mud. I don't know, but it looks like running something with java on an Alpine host is a difficult climb compared to Ubuntu server.
Trying to run it again under root user just to see if there's a difference but looks like it'll fail the same way. Docker on an Alpine host is just a big fail whale atm.
Screenshot of the error
test.cfm
Copy code
<cfset local.xmlVar = xmlformat(createObject("java", "java.net.InetAddress").getLocalHost().getHostName())>
<cfscript>
	writedump(xmlVar);

	private string function getMachineName() output=false {
		try {
			cfexecute( arguments="", variable="local.machineNameResult", name="hostname", timeout=10 );
			return Trim(local.machineNameResult);
		} catch (any cfcatch) {
			writeDump( var=cfcatch );
			abort;
		}
	}

	writeOutput(getMachineName().toString());

</cfscript>
That test file runs fine with my docker image under Ubuntu but not Alpine.
Could be DNS related.. I am noticing that Ubuntu pulls in my /etc/resolve.conf info (given how my parameters are) but the same does not happen under Alpine. Will see if manual population of it will resolve it. https://community.oracle.com/tech/developers/discussion/1148912/java-doesnt-pick-up-systems-dns-settings-change-until-restarted
I don't know.. in my test file I can pull in the hostname fine but then when I try to implement it in code elsewhere it fails, but again only on Alpine. It's really bizarre and not consistent at all in how this docker setup works between Alpine & Ubuntu. Error invoking external process
Copy code
cfexecute( arguments="", variable="local.machineNameResult", name="hostname", timeout=10 );
d
I would take Lucee out of the equation and just try running the code straight from Java. Here's an example class that you should be able to run from the Java CLI: https://www.javatpoint.com/java-inetaddress-gethostname-method If you save that class as "JavaInetAddressGetHostNameExample1.java", then you should be able to do:
Copy code
java -cp . JavaInetAddressGetHostNameExample1
Oops, you'll need to compile it first:
Copy code
javac JavaInetAddressGetHostNameExample1.java
g
And after removing that line completely it just fails on db queries.. Seems like there is just some sort of permissions issue.
Copy code
Lucee 5.3.8.189 Error (java.lang.RuntimeException) Message lucee.commons.lang.ClassException: cannot load class through its string name, because no definition for the class with the specified name [com.microsoft.sqlserver.jdbc.SQLServerDriver] could be found caused by (java.lang.ClassNotFoundException:com.microsoft.sqlserver.jdbc.SQLServerDriver;java.lang.ClassNotFoundException:com.microsoft.sqlserver.jdbc.SQLServerDriver not found by lucee.core [48];) StacktraceThe Error Occurred in
 /org/lucee/cfml/Query.cfc: line 227 
 called from /org/lucee/cfml/Query.cfc: line 37 
 
								called from /app/Application.cfc: line 525
							 
523: SET NOCOUNT OFF;
 524: ");
 525: var res = qry.execute();
 526: var saveLog = res.getResult();
 527:
@dswitzer compile it? Why? This is in a docker image, and it works fine under Ubuntu Server. What's different about running it under Alpine?? Shouldn't the image be the same?
Copy code
FROM ortussolutions/commandbox:lucee5-alpine
Ok, trying to compile this and see what happens
@dswitzer the "java -cp . JavaInetAddressGetHostNameExample1" command returns nothing at all on the Alpine docker image, but works as expected on the docker image running on the Ubuntu server. :/
ran it with debug and this is what I get on Alpine
Copy code
[0.508s][info][class,load] java.util.concurrent.atomic.Striped64$1 source: jrt:/java.base
[0.509s][info][class,load] java.lang.SecurityException source: jrt:/java.base
[0.509s][info][class,load] jdk.internal.misc.TerminatingThreadLocal$1 source: jrt:/java.base
[0.510s][info][class,load] java.lang.Shutdown source: jrt:/java.base
[0.510s][info][class,load] java.lang.Shutdown$Lock source: jrt:/java.base
What I get on ubuntu (note I start off w/ concurrent, because thing diverge btwn the 2 at that point.
Copy code
[0.629s][info][class,load] java.util.concurrent.atomic.Striped64$1 source: jrt:/java.base
[0.632s][info][class,load] java.net.InetAddress$CachedLocalHost source: jrt:/java.base
[0.634s][info][class,load] java.lang.Readable source: jrt:/java.base
[0.635s][info][class,load] java.nio.CharBuffer source: jrt:/java.base
[0.636s][info][class,load] java.nio.HeapCharBuffer source: jrt:/java.base
[0.637s][info][class,load] java.nio.charset.CoderResult source: jrt:/java.base
rrvmus
[0.639s][info][class,load] jdk.internal.misc.TerminatingThreadLocal$1 source: jrt:/java.base
[0.640s][info][class,load] java.lang.Shutdown source: jrt:/java.base
[0.641s][info][class,load] java.lang.Shutdown$Lock source: jrt:/java.base
d
It sounds like there's a DNS resolution issue with the Docker environment (which sounds like you knew, but this just confirms that the issue is not with Lucee but with Java not being able to resolve the name).
g
No - you're focusing on the wrong thing it is related to java itself - even after I stop trying to resolve the hostname java is throwing errors about anything and everything. @dswitzer
Here's the version installed on the Alpine host
Copy code
java -version
openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)
The version installed on the Ubuntu host
Copy code
java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
d
g
Already tried a couple of the suggestions, I manually popular the DNS already, & I also bridge the network to host already. I am beginning to think it is more about the specific version of java that is installed that anything else. Resolving the hostname I don't think matters as I get errors and DB queries too. The CLI on the docker image itself seems to work fine, I can ping and access the IPs and hostnames on the LAN that I'd expect.
Maybe it is just a routing issue.. I am having to forward ports in a weird way
Yea - it was may really odd port forwarding sitaution come to find out 😕
I appreciate the help @dswitzer! The issue ended up being needing to just make sure that my iptables were running.. they were not.
Copy code
sudo /etc/init.d/iptables save
sudo /etc/init.d/iptables start
d
@gbit Glad to hear you figured it out!