segmentationFault
segmentationFault

Reputation: 51

How to connect postgresql with PGAdmin in docker-compse.yml file

This is my docker-compose.yml file:

version: "3.9"
   
services:
  db:
    image: postgres
    volumes:
      - ./data/db:/var/lib/postgresql/data
      - ./innovators.sql:/docker-entrypoint-initdb.d/innovators.sql
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
  
  pgadmin:
    image: dpage/pgadmin4:4.18
    restart: unless-stopped
    environment:
      - [email protected]
      - PGADMIN_DEFAULT_PASSWORD=admin
      - PGADMIN_LISTEN_PORT=80
    ports:
      - "8090:80"
    volumes:
      - ./pgadmin-data:/var/lib/pgadmin
    links:
      - "db:pgsql-server"


  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

volumes:
  pgadmin-data:

In postgreql I import my own table (./innovators.sql:/docker-entrypoint-initdb.d/innovators.sql).

What should I do to connect my postgresql database with my pgAdmin?

I wish the end result would be that I can see my tables which I imported in pgadmin.

Upvotes: 1

Views: 1984

Answers (1)

Michal Rosenbaum
Michal Rosenbaum

Reputation: 2061

Access pgadmin in the browser on your host on localhost:8090. Sign in and then navigate to Servers->Create->Server, in the connection tab use db or pgsql-server as "Host name/address" and 5423 as a port.

Upvotes: 4

Related Questions