skip to Main Content

I’ve run my docker-compose file trying to dockerize pgadmin for Postgres but my browser cannot connect to pgadmin on url localhost:8080.

This is the docker-compose file that I am running

version: '3'
services:
  db:
    container_name: postgres_container
    image: postgres
    restart: always
    environment:
      POSTGRES_DB: postgres_db
      POSTGRES_USER: admin
      POSTGRES_PASSWORD: secret
      PGDATA: /var/lib/postgresql/data
    ports:
      - "5432:5432"
    volumes:
      - db-data:/var/lib/postgresql/data

  pgadmin:
    container_name: pgadmin4_container
    image: dpage/pgadmin4:5.5
    restart: always
    environment:
      PGADMIN_DEFAULT_EMAIL: [email protected]
      PGADMIN_DEFAULT_PASSWORD: secret
      PGADMIN_LISTEN_PORT: 80
    ports:
      - "8080:80"
    volumes:
      - pgadmin-data:/var/lib/pgadmin
volumes:
  db-data:
  pgadmin-data:

This is my docker ps

CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                           NAMES
c6a6a588f639        dpage/pgadmin4:5.5   "/entrypoint.sh"         3 hours ago         Up 9 minutes        443/tcp, 0.0.0.0:8080->80/tcp   pgadmin4_container
ad6fe3349717        postgres             "docker-entrypoint.s"    3 hours ago         Up 9 minutes        0.0.0.0:5432->5432/tcp          postgres_container

When I try to connect to it from browser to localhost:8080 it says Connection attempt failed

2

Answers


  1. Chosen as BEST ANSWER

    I solved this problem. Turns out that DOCKER_HOST variable was set to 192.168.99.100:2376. You can see it by running command echo $DOCKER_HOST I just ran my docker container into this port instead of localhost and everything worked fine.

    docker run -d -p 192.168.99.100:9411:9411 openzipkin/zipkin
    

    And I was able to access my docker container through the browser by url http://192.168.99.100:9411/ Thank you very much everyone


  2. I am using almost the same docker compose file on Windows 10 with WSL 2 and can connect immediately using Firefox build 100 browser to localhost:8080.
    My difference is that the image for pgadmin4 in the compose file is image: dpage/pgadmin4

    • the latest not v5.5
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search