Skip to main content

Docker run and network process (For postgres)

Bullet steps and commands

maven clean install and build the dockerfile

docker network ls

docker network rm network01

Remove any existing networks

docker network create network01

Build the container of your Postgres image - alternatively use values that you have used in application.properties

docker run -d --name some-postgres03 --net network01 -e POSTGRES_USER=test01 -e POSTGRES_PASSWORD=runtest -p 5433:5432 postgres

Build a docker image of your spring boot application or use UI

docker build -t composetesting .

Use the image and finally build a connected docker container of your application with its env values, alternatively use values that you have used in application.properties

docker run -d --name compose-testing --net network01 -e DB_HOST=some-postgres03 -e DB_PORT=5432 -e DB_USERNAME=test01 -e DB_PASSWORD=runtest -p 8082:8082 composetesting

note, you can use docker inspect <container name &gt; to get the ip address as the host address also

Was this page helpful?