0

I have one container of springboot application on docker,and one container of postgres with all the settings.How can I run both of them by linking them together. The image springboot-postgresql corresponds to spring boot application,and postgres refers to postgresql. Postgres is listening to 0.0.0.0,port 5432.

enter image description here

Please suggest,if there's another way other than making a .yml file and using docker compose up . Thanks for the help.

1 Answer 1

1

The way you can communicate between each container is using docker network,

First, you need to create a network:

$ docker network create sprintapp

Above, the command creates a network named sprintapp

Then, you need to specify to a container to be inside the network:

$ docker run --name [CONTAINERNAME] --network sprintapp [IMAGE]

This way, all containers within the network could talk to each other, using [CONTAINERNAME] as the URI to locate it.

More info about this:

docker run reference

docker network reference

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.