OpenProject with an external PostgreSQL database

Hi,
I’m sorry for this question but I have tried to find the answer to no avail.
I want to connect to an external PostgreSQL docker container from an OpenProject container:
Here is the docker-compose.yml file of Postgre:

version: "3.7"

services:
  postgres:
    image: postgres
    user: root
    container_name: local_pgdb
    ports:
      - "5432:5432"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRE_DB: postgres
    volumes:
      - ./var/lib/postgresql/data:/var/lib/postgresql/data

  pgadmin:
    image: dpage/pgadmin4
    user: root
    container_name: pgadmin4_container
    environment:
      PGADMIN_DEFAULT_EMAIL: xxxx@yyyy.com
      PGADMIN_DEFAULT_PASSWORD: password
      PGADMIN_LISTEN_PORT: 8001
    ports:
      - "8001:8001"
    depends_on:
      - postgres
    volumes:
      - ./var/lib/pgadmin:/var/lib/pgadmin

It is the docker-compose.override.yml file of my OpenProject container:

version: "3.7"

x-op-app: &app
  environment:
	DATABASE_URL: "postgresql://postgres:postgres@172.18.0.2:543/openproject"

services:
  db:
    deploy:
      replicas: 0

I created the openproject database in the PostgreSQL, too.

Unfortunately the OpenProject is not reachable.

Running ‘sudo docker compose logs’ I found this message:

PG::ConnectionBad: could not translate host name “db” to address: Temporary failure in name resolution

What can be the problem, please?

What do you want to achieve with this?

services:
  db:
    deploy:
      replicas: 0