Having trouble to configure networking between containers

Hey all,

have docker container issue where a python flask container is not able to talk with postgresql container
can any one help with that ?

Issue type: configure networking between containers
Steps to reproduce:

you have docker installed on your machine,
git clone https://github.com/vaibhav-rbs/testdriven-app
docker-compose up -d --build
docker-compose exec users python manage.py test

test_app_is_development (test_config.TestDevelopmentConfig) ... ok
test_app_is_production (test_config.TestProductionConfig) ... ok
test_app_is_testing (test_config.TestTestingConfig) ... FAIL
test_users (test_users.TestUserService)
Ensure the /ping route behaves correctly. ... ERROR

docker -v
Docker version 18.09.2, build 6247962
uname
Darwin

SO there are two way you can make one container access another container service.(lets take your example of one postgres container and one flask container).
First, map the postgres port in container(postgres one) to host using ports property in docker compose file. Then configure you flask to access the host ip with port you map with. (check the ports section in this link for more info https://docs.docker.com/compose/compose-file/)

secondly, if you want your postgres not be access by others and only be access by flask. Create your user defined network(link - https://docs.docker.com/engine/reference/commandline/network_create/). then give this network in both compose files(check 1st link). Then configure flask with postgres container name with port.
Hope this we help

And third, the containers are already connected to each other (if they are running).

docker-compose exec users ping users-db
docker-compose exec users-db ping users

And one thing to your compose file: Did you notice you configured Postgres at users-db:5342? Pg normally runs on 5432. Just don’t specify the port if it’s the default.

yep that was it, this was such a small issue. thanks for all the help :smiley: