简体   繁体   中英

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:
      - PGADMIN_DEFAULT_EMAIL=admin@domain.com
      - 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM