After search on stackoverflow feels like it is common problem, but I didn't found the decision.
Without docker the program works on localhost. The docker file:
FROM openjdk:8
ADD target/DockerMyBlog.jar DockerMyBlog.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "DockerMyBlog.jar"]
The application.properties (did attempt to replace "localhost" over here for "dockermyblog"):
jdbc.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/javastudy
jdbc.username=hey
jdbc.password=hey
Creating container by command in terminal:
docker build -t dockermyblog .
Trying to launch it by:
docker run -p 8080:8080 dockermyblog
Receive an error:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:829)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:449)
......................
Tried to set (without understanding what's that):
jdbc:mysql://localhost:3306/javastudy?enabledTLSProtocols=TLSv1.2
or
jdbc.url=jdbc:mysql://dockermyblog:3306/javastudy?autoReconnect=true&useSSL=false
Tried to put in terminal:
docker inspect dockermyblog | grep IPAddress
Terminal does not know "grep"
What should I do to launch it locally