How to create a new database in already existing postgres container?

Viewed 1805

I was trying to create a new database in my already existing postgres container.

But it is skipping the database initialization part.

I am getting this message after running the docker-compose up command: "PostgreSQL Database directory appears to contain a database; Skipping initialization"

docker-compose.yml

    version: '3'
    services:
        db:
           container_name: db
           environment:
               POSTGRES_DB=new_db_name
           volumes:
               - pgdata:/var/lib/postgresql/data
        app:
           container_name: app
           depends_on:
               - db

I am providing new database name. So it should create a new database, right?

But it is not happening.

Please help.

1 Answers
Related