I'm a new user of docker I have build my app and now I want to test the image of my app with postgres since it using a postgres Database. I'm using a postgres image too.
This is my image:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my_app 2.5-SNAPSHOT 6416734dcf5a 53 years ago 518MB
This is how i launch postgres:
docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres
I tried to run my_app like this:
docker run --name my-app --link my-postgres:postgres -p 8080:8080 -d 6416734dcf5a
But i got this error:
org.flywaydb.core.internal.exception.FlywaySqlException: Unable to obtain connection from database:
Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL State : 08001
Error Code : 0
Message : Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
I was wondering if there is a way to launch my_app in a network, so that I can avoid this error.