Search code examples
dockerdocker-composeodooodoo-15linux-mint-21

Odoo server is not accessible when running with docker-compose


I am trying to run Odoo using docker-compose. I have followed the instructions here. I can start the Postgres and Odoo servers using Docker and access the Odoo server correctly. When I run the first 'simplest' docker-compose example, it appears to start the Postgres server correctly but after a few minutes an error message appears from the web server:

    Attaching to testdocker_db_1, testdocker_web_1
db_1   | 
db_1   | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1   | 
db_1   | 2022-09-01 14:54:47.015 UTC [1] LOG:  starting PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
db_1   | 2022-09-01 14:54:47.016 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
db_1   | 2022-09-01 14:54:47.016 UTC [1] LOG:  listening on IPv6 address "::", port 5432
db_1   | 2022-09-01 14:54:47.021 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1   | 2022-09-01 14:54:47.027 UTC [26] LOG:  database system was shut down at 2022-09-01 14:54:22 UTC
db_1   | 2022-09-01 14:54:47.033 UTC [1] LOG:  database system is ready to accept connections
web_1  | Database connection failure: connection to server at "db" (172.21.0.2), port 5432 failed: Connection timed out
web_1  |    Is the server running on that host and accepting TCP/IP connections?
web_1  | 
testdocker_web_1 exited with code 1

The docker-compose.yml is copied exactly from the docker hub page except that I noticed I have Postgresql v14 installed so I have changed the postgres image:

version: '3.1'
services:
  web:
    image: odoo:15.0
    depends_on:
      - db
    ports:
      - "8069:8069"
  db:
    image: postgres:14
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_PASSWORD=odoo
      - POSTGRES_USER=odoo

Solution

  • I had installed Docker on my Linux Mint 21 system using snap. I did that because the installation instructions here didn't work on my system.

    I have now been able to install the Docker Debian packages and this problem is solved.

    In order to get the Debian package to install correctly,I changed:

    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
      $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    

    To:

    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
      jammy stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null