如何在 docker-compse.yml 文件中将 postgresql 与 PGAdmin 连接
How to connect postgresql with PGAdmin in docker-compse.yml file
这是我的 docker-compose.yml
文件:
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:
在 postgreql
中我导入了自己的 table (./innovators.sql:/docker-entrypoint-initdb.d/innovators.sql
).
我应该怎么做才能将我的 postgresql 数据库连接到我的 pgAdmin?
我希望最终结果是我可以看到我在 pgadmin 中导入的 tables。
在 localhost:8090
主机上的浏览器中访问 pgadmin。登录然后导航至 Servers->Create->Server
,在连接选项卡中使用 db
或 pgsql-server
作为“主机 name/address”,并使用 5423 作为端口。
这是我的 docker-compose.yml
文件:
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:
在 postgreql
中我导入了自己的 table (./innovators.sql:/docker-entrypoint-initdb.d/innovators.sql
).
我应该怎么做才能将我的 postgresql 数据库连接到我的 pgAdmin?
我希望最终结果是我可以看到我在 pgadmin 中导入的 tables。
在 localhost:8090
主机上的浏览器中访问 pgadmin。登录然后导航至 Servers->Create->Server
,在连接选项卡中使用 db
或 pgsql-server
作为“主机 name/address”,并使用 5423 作为端口。