Docker does not create the database with the correct name

Hello everyone. I am defining 2 containers, 2 services, with docker composer. One is postgres and the other is pgadmin.

The problem is that when I enter the postgrest server credentials in pgadmin, the maintenance database, which I define in the .yml file as “portal”, does not accept the connection and it does accept it if the maintenance database name is “postgres”

as you can see in the following images

and if I set in Maintenance database “portal”. it show up that portal database does not exist

This is the .yml file:

version: '3.8'

services:
      database:
          image: postgres:latest
          container_name: postgres-db
          restart: always
          environment:
              POSTGRES_PASSWORD: postgres
              POSTGRES_USER: postgres
              POSTGRES_DB: portal
          ports:
              - "5432:5432"
          volumes:
              - postgres-data:/var/lib/postgresql/data
              # add entrypoint script to init db
              - ./Dockerfiles/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
          networks:
              app-network:
      
      pgadmin:
          container_name: pgadmin4_container
          image: dpage/pgadmin4:latest
          restart: always
          environment:
              PGADMIN_DEFAULT_EMAIL: admin@admin.com
              PGADMIN_DEFAULT_PASSWORD: root
          ports:
              - "5050:80"
          depends_on:
              - database
  networks:
      app-network:
  
  volumes:
      app-data:
      postgres-data:

and this is the init.sql

    -- Init database for postgres, create user and database
    
    -- Create user
    
    CREATE USER postgres WITH PASSWORD 'postgres';
    
    -- Create database with id and name
    
    CREATE DATABASE portal WITH OWNER postgres;
    
    GRANT ALL PRIVILEGES ON DATABASE portal TO postgres;
    
    -- Create table to docker database with id and name
    
    \c docker
    
    CREATE TABLE test (id SERIAL PRIMARY KEY, name VARCHAR(255));
            
    INSERT INTO test (name) VALUES ('docker 1');
    
    INSERT INTO test (name) VALUES ('docker 2');

Just to react to the title: Docker does not create the postgres database. The application inside the Docker container does or should have.created it.

Have you checked the existence of the database from the command line?