how to access external mysql from docker

I have an springboot java app inside docker that needs to access an external mysql.

How can I configure this? Is it possible to define it inside Dockerfile?

I am now to docker so I assume this should be a simple and common task :)

When I run the app I receive the error

2019-02-12 15:10:51,472 DEBUG [main] com.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Cannot acquire connection from data source java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

my Dockerfile

FROM openjdk:11.0.2-jre-slim
VOLUME /tmp
COPY target/app-0.4-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
EXPOSE 9001/tcp

If the mysql server is running on the docker host, either on metal or in another contianer with a mapped port, it could be that your app's configuration is still looking for the database server on localhost which within its container points to the loopback interface INSIDE the container.

You can get around this with the special address: host.docker.internal see info

Where is this external mysql server?

of course…I don’t know why I haven’t think of that @v25 can you answer I will accept it