we are deploying a docker-image using this command:
cf ic run -p 8080 -m 512 -e SPRING_PROFILES_ACTIVE=test -e logging.config=classpath:logback-docker-test.xml --name <container-name> registry.eu-gb.bluemix.net/<repository_name>/<container-name>:latest
Within that container we are starting a Java8 Spring-Boot application that uses a connection-pooling provider. The connection-pooling provider connects to an existing PostgreSQL-Database that is accessible on the standard port. We do not use any domain name to connect to PostgreSQL-Database. We only use the IP-Address and the standard postgresql port.
The deployment is working on a machine that uses the standard Docker container daemon and is also working on Amazon WebServices (AWS) without any problems and using the same deployment mechanism.
However, if we are deploying the image to the Bluemix-Container-Service we do get the following error at startup of the spring-boot application:
Caused by: java.net.NoRouteToHostException: No route to host
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.postgresql.core.PGStream.<init>(PGStream.java:61)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:129)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:146)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:35)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:47)
at org.postgresql.jdbc42.AbstractJdbc42Connection.<init>(AbstractJdbc42Connection.java:21)
at org.postgresql.jdbc42.Jdbc42Connection.<init>(Jdbc42Connection.java:28)
at org.postgresql.Driver.makeConnection(Driver.java:415)
at org.postgresql.Driver.access$100(Driver.java:47)
at org.postgresql.Driver$ConnectThread.run(Driver.java:325)
... 1 more
We don't know why this happens, because if we do a telnet on another Bluemix-Docker-Machine to the PostgreSQL-Database server with the desired port everything is fine.
This is very annoying, since we cannot use this Docker-Image on Bluemix currently and is currently obstructing our planned roll-out.
Can you help us with details what might be wrong and how can fix this?
Any help will be appreciated.
Regards,
Christian
Is this error raised when the container is starting up?
If so, the Docker/IBM Containers on Bluemix take about between 30 up to 60 seconds in networking status: during this phase the container is not able to connect to the network.
It should be really probably the root cause of the error you are getting: if the Java SpringBoot application is trying to connect to the PostgreSQL database when the container is still in networking phase, it will fail with this error.
You should start your application running on the container when the container has completed the networking phase (for example through a bash script that checks the availability of the PostgreSQL server, or simply configure your springboot to manage this exception)
Official bluemix support gave the hint to wait for 120 seconds before starting the Java-Application that needs network access. The suggested way is:
CMD ["/bin/sh", "-c", "sleep 120; exec java $JVM_ARGS -cp /app org.springframework.boot.loader.JarLauncher --spring.main.show_banner=false"]
With that we have got network access and everything is fine.
Related
an spring boot app can run from console A., but I get connection refused when it runs by docker run B.
A. from console it works
java -Dspring.profiles.active=loc -jar app.war
B. Dockerfile
docker run -e "SPRING_PROFILES_ACTIVE=loc" app
ENTRYPOINT java -jar $WDIR/app.war
Why I get this error ?
Thanks in advance.
Csaba
You need to check your application properties/yaml for network access. For example; if you have database connection in properties you need check access of database. If you have container database you need to access via container name or for external remote access you can explore docker network
I am trying to deploy spring boot docker image stored at Docker Registry to Cloud Run.
However, when I deployed the image, I got the error;
Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.
I understand this could be caused by port and address setting, so I fixed these parts referring the official doc, though still experiencing the same error. Concretely, I set these things as below, on application.yml.
server:
port: ${PORT:8080}
address: ${ADDRESS:localhost}
I understand PORT variable would be passed by Cloud Run(in my case, port num is set to 8080 on Cloud Run). And also ADDRESS will be passed to by myself(the value is 0.0.0.0, referring the official doc).
For reference, the below is my Dockerfile building spring boot docker image;
# Stage1 - execute build process
FROM openjdk:14-jdk-alpine as build_process
WORKDIR /back_end
COPY . .
RUN ./gradlew build -x test
# Stage2 - boot app with the build output above
FROM openjdk:14-jdk-alpine
EXPOSE ${PORT}
COPY --from=build_process /back_end/build/libs/back_end-0.0.1-SNAPSHOT.jar ./app.jar
RUN adduser -D user
USER user
ENTRYPOINT ["sh","-c","java -jar app.jar"]
Any help would be really appreciated. Thank you so much for reading!
I figured it out why my docker image had failed Cloud Run's health check. After all, it is not about Port and IP address, but about the timing when the health check process executes.
The health check process seems to start immediately once the image is deployed, though my case it took almost 30 secs to launch spring boot tomcat server after deploying to Cloud Run.
That led to the failure of the health check process, so I fixed settings to launch tomcat server immediately too, which solved the issue I posted.
looks like this
using windows version 10,
docker for windows(docker verion) : 18.09.2
how to resolve this issue ?
Kubernetes should be running.
But check your cluster-info:
> kubectl cluster-info
Kubernetes master is running at http://localhost:8080
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
That is reported both in docker/machine and docker/for-win or kubernetes/minikube.
While the issue is pending, and if no firewall/proxy is involved, I have seen the error caused because the port is already taken.
See also this article:
Issue
The reason you are getting the error message is that Kuberentes is not looking into the correct configuration folder because the configuration path is not configured on the Windows 10 machine.
Solution
To fix the problem, I will run the command below that will tell Kubernetes where to find the configuration file on the machine.
Powershell
[Environment]::SetEnvironmentVariable("KUBECONFIG", $HOME + "\.kube\config", [EnvironmentVariableTarget]::Machine)
I have been trying to get a local copy of Storm working, following the guide in the storm-starter repo, and this tutorial.
When trying to run a topology with mvn compile exec:java -Dstorm.topology=org.apache.storm.starter.ExclamationTopology, the output eventually continues looping & spamming:
28534 [Thread-9-SendThread(localhost:2000)] INFO o.a.s.s.o.a.z.ClientCnxn - Opening socket connection to server localhost/127.0.0.1:2000. Will not attempt to authenticate using SASL (unknown error)
28534 [Thread-9-SendThread(localhost:2000)] WARN o.a.s.s.o.a.z.ClientCnxn - Session 0x152f7728a6a0011 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[?:1.8.0_45]
at Sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[?:1.8.0_45]
at org.apache.storm.shade.org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361) ~[storm-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
at org.apache.storm.shade.org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081) [storm-core-2.0.0-SNAPSHOT.jar:2.0.0-SNAPSHOT]
It seems it is trying to connect to a local Zookeeper cluster, but I have not seen the dependency or install requirement for Zookeeper in the Storm docs or in this other tutorial.
Do I need to install Zookeeper and is this just missing from the docs? Perhaps I'm mistaken and it is looking for something else at port 2000 on my localhost? If not, what is going wrong in my local setup?
If you run locally and use LocalCluter you do not need to install Zookeeper.
If you run locally in pseudo-distributed mode (ie, start up Nimubs and Supervisor locally) and use StormSubmitter you do need to install Zookeeper locally.
I have downloaded apache karaf2.3.3 (on felix) on several CentOS6.4 machines. I see this issue only in a few machines. When I try to install a feature using the following commands
$KARAF_HOME/bin/start
$KARAF_HOME/bin/client "features:install myfeature"
I get the following stack trace:
WARN org.apache.sshd.client.session.ClientSessionImpl - Exception caught
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:379)
at org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:273)
at org.apache.mina.transport.socket.nio.NioProcessor.read(NioProcessor.java:44)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:690)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:664)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:653)
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$600(AbstractPollingIoProcessor.java:67)
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1124)
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Looks like client fails to connect to karaf. Firewall is shutdown on all of the machines. Anyone knows why this could be failing? The feature gets happily installed if run karaf in console mode with /bin/karaf and type in the same command
My guess is that the port you defined for the remote Karaf console was already in use by another application before the Karaf installation. As such the wrong application accepts the link, cannot make anything of the data and resets the connection. I would suggest to stop Karaf, check with netstat or via telnet localhost <port> whether the port Karaf is configured to listen on is already in use, and find the related application. As an alternative, you can configure Karaf to use a different (not used) port. See for example this page