Okay, the issue I had personally (you most likely have the same) I didn't use his settings in docker-compose.yml file for database.
I actually had a container with many databases running so I decided to stick to my existent database.
--name YOUR_DOCKER_CONTAINER_NAME-api - in your case it might be different.
--network DATABASE_NETWORK -
if you have your database container running, just use the command:
docker network ls
it will list all of your networks. You're interested in the Name of your database ID's container. In my case it's hibernate-starter_default Basically, we need to connect the container to this bridge.
YOUR_DOCKER_ACCOUNT/YOUR_CONTAINER_NAME-api - see the info in the docker repository it is a new container you have pushed.
Okay, the issue I had personally (you most likely have the same) I didn't use his settings in docker-compose.yml file for database. I actually had a container with many databases running so I decided to stick to my existent database.
docker run -d --name YOUR_DOCKER_CONTAINER_NAME-api --rm -p 8080:8080 --network DATABASE_NETWORK YOUR_DOCKER_ACCOUNT/YOUR_CONTAINER_NAME-api --spring.datasource.url=jdbc:postgresql://THING_WE_ARE_LOOKING_FOR:5432/customer
-d - detached mode
--name YOUR_DOCKER_CONTAINER_NAME-api - in your case it might be different.
--network DATABASE_NETWORK -
if you have your database container running, just use the command:
docker network ls
it will list all of your networks. You're interested in the Name of your database ID's container. In my case it's hibernate-starter_default Basically, we need to connect the container to this bridge.
YOUR_DOCKER_ACCOUNT/YOUR_CONTAINER_NAME-api - see the info in the docker repository it is a new container you have pushed.
--spring.datasource.url=jdbc:postgresql://THING_WE_ARE_LOOKING_FOR:5432/customer - it's really tricky one.
docker inspect ID_DATABASE_CONTAINER -f "{{json .NetworkSettings.Networks }}"
It will give you something like this:
You may use any Aliases name, like hibernate-starter-db-1 or db or 8543027d7b75 so in my case, I use
--spring.datasource.url=jdbc:postgresql://db:5432/customer