Skip to content
Advertisement

Containerized spring boot application with oracle database resetting connection

I am having a problem with a containerized spring boot application using oracle database. I successfully build my image but when I run it using docker the application gets stuck on getting a connection pool. The application runs with a connection reset exception and if I try to connect on it I get another connection reset exception, but if I refresh the page the application works normally until I try to use the application again later.

The Dockerfile is configured as follows:

JavaScript

The application properties are pretty standard as well:

JavaScript

I’m building the image and running the docker container with the following commands:

JavaScript

I have tried several things:

  1. Googling the problem I found out that Oracle has entropy issues when running inside Linux so I added -Djava.security.egd=file:/dev/./urandom
  2. That didn’t work so I tried haveged tool for entropy. I didn’t know exactly where to install it so I tried installing it in both places (inside the container using RUN apk -U add haveged and on the host machine (which is a ubuntu xenial 16.04.4))
  3. That didnt work either so I tried to “hack it” by removing /dev/random from the container and replacing it with a symbolic link using ln -s /dev/urandom /dev/random, but even that didn’t work so I tried changing the java.security property securerandom.source=file:/dev/random

No options from above worked so I tried using HikariCP connection pooling but I had the same exception.

The stack trace for the exception :

JavaScript

Advertisement

Answer

Ok, none of the things that I tried worked so I tried the following: I changed the Linux distribution from Ubuntu to CoreOS (which is made specifically for container use) and now it works great. The only problem is that CoreOS is a couple of versions behind with Docker, so I am limited in the things that I could use.

Advertisement