I have 3 machines connected by docker overlay network. I stated a db service(postgres) from Manager Node and from worker node I want to connect my webapp(here odoo 15, community) to that postgres service and save all data there.
How can i do this?
Please share your compose file, so we can see how you actually configure the stack.
If you are not using a compose file for your deployments, you should start doing so.
Make sure all containers are attached to the same overlay network. Overlay networks provide build-in dns-based service discovery. To communicate with another container in the same container network, use the service name to address other containers. Do not use the other container’s ip to communicate with it, as it is ephemeral and will change with every change to the service configuration.
I still not started using compose file. In compose.yml file, how I use default ingress networks ? and what is the way of use --constraint flag of docker service create command???
for example: In odoo image,
if we want to run a postgres container we say:
$ docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name db postgres:14.5
and then we run odoo image service by giving:
docker run -p 8069:8069 --name odoo --link db:db -t odoo
Now if we write docker service cli,
Then we write postgres like this,
docker service create --name db --mode global --network ingress --publish target=5432,published=5432 -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres postgres:14.5
Then how we are going to write odoo service with depends_on postgres service???