12

Have some simple docker-compose.yml file configuration, but I am not sure why I can't not login to pgAdmin using [email protected] as email and admin as a password. Does it need more configuration or am I using wrong credentials?

version: "3.7"

services:
    db:
        image: postgres:13.1
        restart: unless-stopped
        env_file:
            - ./.env
        ports:
            - 5432:5432
        volumes:
            - db-data:/var/lib/postgresql/data
            - ./init-db.sh:/docker-entrypoint-initdb.d/init-database.sh
        networks:
            - appNetwork

    pgAdmin:
        container_name: pgAdmin
        # restart: unless-stopped
        image: dpage/pgadmin4:4.29
        environment:
            PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
            PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
            PGADMIN_LISTEN_PORT: 5050
        volumes:
            - pgadmin:/root/.pgadmin
        ports:
            - "5050:5050"
        depends_on:
            -   db
        networks:
            - appNetwork

volumes:
    db-data:
    pgadmin:

networks:
    appNetwork:
        driver: bridge

enter image description here

2
  • I had the same issue with admin/admin credentials, it seems the email needs to be an email string and not just any username. It worked with [email protected].
    – ymoreau
    Nov 16, 2021 at 14:28
  • 2
    the docker pgadmin image is crap am sorry to day. seems i may have to create my own image. The error messages are the worst. Docker containers should not be rocket science like this
    – uberrebu
    Aug 17, 2022 at 2:55

5 Answers 5

17

You define PGADMIN_DEFAULT_EMAIL and PGADMIN_DEFAULT_PASSWORD and also use a persistent volume pgadmin. Maybe you previously created an instance with a different email/password which have been persisted in pgadmin volume and is not overriden by your newly defined variables.

You can try to delete stack containers and volumes with:

# WARNING: this will delete all containers and volumes
# including pg_data volume and pgadmin volume
# make sure to make a backup if needed
docker-compose down -v 

Alternatively, you can just stop pgAdmin container and specifically delete the pgadmin volume:

docker-compose rm -s pgAdmin

# Replace project_name by your Docker Compose project name
# Use docker volume ls to show all volumes and choose the proper one
docker volume rm project_name_pgadmin

Then re-create pgAdmin container and volume (and if necessary other components):

docker-compose up -d
6
  • Thank you, used first solution. But sadly same result.
    – galvakojis
    Jan 8, 2021 at 14:36
  • Do you have a .env in your local folder that may overrides these variables?
    – Pierre B.
    Jan 8, 2021 at 15:41
  • I have but they are the same. Interesting to know that using this command I was able to login docker run -p 5050:80 -e "[email protected]" -e "PGADMIN_DEFAULT_PASSWORD=test1234" -d dpage/pgadmin4:4.29 But not using .yml configurations
    – galvakojis
    Jan 8, 2021 at 16:06
  • 1
    https://stackoverflow.com/a/61020606/2956929 used this link, I am still not sure why it is working now, or why is was not working before
    – galvakojis
    Jan 8, 2021 at 16:47
  • Thank you, it worked for me. I am using mac m1 machine and this script was the missing jigsaw piece I was looking for. Jun 16, 2022 at 12:29
2

Maybe you already used the service pgAdmin and it related container: container_name: pgAdmin

The solution would be to give them other names as follow:

pgAdminNew:
    container_name: pgAdmin_new
    # restart: unless-stopped
    image: dpage/pgadmin4:4.29
    environment:
        PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:[email protected]}
        PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
        PGADMIN_LISTEN_PORT: 5050
    volumes:
        - pgadmin:/root/.pgadmin
    ports:
        - "5050:5050"
    depends_on:
        -   db
    networks:
        - appNetwork
1

I solved it by deleting the container first, and then deleting the volume. In your case, delete the volume named pgadmin.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Sep 17, 2022 at 4:06
1

Additional to all the solutions above, make sure that Postgres is not running on the local machine out of Docker because it might conflict with the Postgres instance in Docker

0
1

For me it was not working for any of the below users:

‘PGADMIN_DEFAULT_EMA[email protected]’
'[email protected]'

Then I used a different one:

'[email protected]'

And it worked. Not sure what's the reason may be the other two are too common.

1
  • This is the only thing that worked for me. Take my upvote!
    – Saqlain
    Nov 15 at 3:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.