H2 console not working on Docker (remote connections ('webAllowOthers') are disabled)

Viewed 1163

I have an api application which works on port 8080 with h2 db and h2-console is working good when I run the application from the IDE.

I have dockerized the project with dockerfile and docker-compose.yml, the project is working without problem, everything seems fine except that I cannot reach the h2-console when I run the project from docker.

Am getting the error: "Sorry, remote connections ('webAllowOthers') are disabled on this server."

I checked some solutions and applied

spring.h2.console.settings.web-allow-others=true

to application-DOCKER.properties and also application.properties file but still cannot see the h2 console when I run the project on docker.

How can I solve this?

2 Answers

Make sure to not have any spaces around comma:

Instead of : ENTRYPOINT ["java", "-jar", "/app.jar", "-web -webAllowOthers -tcp -tcpAllowOthers -browser"]

For below worked:

ENTRYPOINT ["java","-jar","/app.jar","-web -webAllowOthers -tcp -tcpAllowOthers -browser"]

i had the same problem. I found this answer after researching this problem.

Before starting jar in the Dockerfile, you can make it start by giving the following arguments. ("-web -webAllowOthers -tcp -tcpAllowOthers -browser")

My Dockerfile;

FROM openjdk:8-jdk-alpine
ADD target/*.jar app.jar
ENTRYPOINT ["java", "-jar", "/app.jar", "-web -webAllowOthers -tcp -tcpAllowOthers -browser"]
EXPOSE 8080

In this way, I hope there will be no problems.

Related