POSTGRES unable to connect with container

rayden 41 Reputation points
2022-10-17T08:59:50.48+00:00

I tried implementing Postgres with Odoo in Azure through docker compose, I faced this error when I tried to check Odoo's container logs :

Database connection failure: connection to server at "db" (127.0.0.1), port 5432 failed: Connection refused Is the server running on that host and accepting TCP/IP connections ?

Here's my docker-compose.yml

version: '3.2'  
  
services:  
   db:  
     image: registryodoo.azurecr.io/samples/postgres:13  
     volumes:  
       - db:/var/lib/postgresql/data/pgdata  
     deploy:  
      restart_policy:  
        condition: always  
     expose:  
       - 5432  
     environment:  
       POSTGRES_PASSWORD: odoo  
       POSTGRES_DB: postgres  
       POSTGRES_USER: odoo  
       PGDATA: /var/lib/postgresql/data/pgdata  
  
   odoocontainer:  
     depends_on:  
       - db  
     image: registryodoo.azurecr.io/samples/odoo:latest  
     volumes:  
      - data:/var/lib/odoo  
      - extra-addons:/mnt/extra-addons  
     ports:  
       - 8069:8069  
     deploy:  
      restart_policy:  
        condition: always  
     environment:  
       HOST: db  
       USER: odoo  
       PASSWORD: odoo  
volumes:  
  data:     
    driver: azure_file  
    driver_opts:  
      share_name: odoofileshare  
      storage_account_name: odooaccount1  
  db:  
    driver: azure_file  
    driver_opts:  
      share_name: odoofileshare  
      storage_account_name: odooaccount1  
  
  extra-addons:  
    driver: azure_file  
    driver_opts:  
      share_name: odoofileshare  
      storage_account_name: odooaccount1  

After looking at some answers in related questions I tried with : expose : - 5432 , ports : - 5432 and not writing it in the docker compose, I still had the same issue.

Here's the container logs:

250970-image.png

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
658 questions
0 comments No comments
{count} votes

Accepted answer
  1. rafalzak 3,216 Reputation points
    2022-10-17T10:19:53.637+00:00

    Hi @rayandenfir-1568,

    It's state is terminated - in short, it didn't start at all so it's a reason why you cannot connect there.
    Try to add command after the image:

    command: tail -f /dev/null  
    

0 additional answers

Sort by: Most helpful