11

Have some simple docker-compose.yml file configuration, but I am not sure why I can't not login to pgAdmin using pgadmin4@pgadmin.org 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:-pgadmin4@pgadmin.org}
            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

galvakojis
  • 408
  • 1
  • 5
  • 19
  • 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 `admin@whatever.com`. – ymoreau Nov 16 '21 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 '22 at 02:55

4 Answers4

15

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
Pierre B.
  • 11,612
  • 1
  • 37
  • 58
  • Thank you, used first solution. But sadly same result. – galvakojis Jan 08 '21 at 14:36
  • Do you have a .env in your local folder that may overrides these variables? – Pierre B. Jan 08 '21 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 "PGADMIN_DEFAULT_EMAIL=pgadmin4@pgadmin.org" -e "PGADMIN_DEFAULT_PASSWORD=test1234" -d dpage/pgadmin4:4.29``` But not using .yml configurations – galvakojis Jan 08 '21 at 16:06
  • ```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 08 '21 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. – Meet Zaveri Jun 16 '22 at 12:29
  • yes! the docker-compose down -v did the trick. – Ron Al Feb 25 '23 at 14:57
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:-pgadmin4@pgadmin.org}
        PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
        PGADMIN_LISTEN_PORT: 5050
    volumes:
        - pgadmin:/root/.pgadmin
    ports:
        - "5050:5050"
    depends_on:
        -   db
    networks:
        - appNetwork
Nasser Abdou
  • 188
  • 2
  • 7
0

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

  • 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](/help/how-to-answer). – Community Sep 17 '22 at 04:06
0

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

Abdelsalam Megahed
  • 1,281
  • 12
  • 13