我已经尝试修复了两天。我遵循了tutorial,使用docker用pgadmin设置postgres。由于我需要Postgis,因此我修改了本教程,以获取以下docker-compose.yml
文件:
version: '3'
services:
fullstack-postgres: # https://hub.docker.com/r/kartoza/postgis/
image: kartoza/postgis:12.0
container_name: full_db_postgres
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASS=${DB_PASSWORD}
- POSTGRES_DBNAME=${DB_NAME}
ports:
- '5432:5432'
volumes:
- ./postgres_data/:/var/lib/postgresql
networks:
- fullstack
pgadmin:
image: dpage/pgadmin4
container_name: pgadmin_container
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
depends_on:
- fullstack-postgres
ports:
- "5050:80"
networks:
- fullstack
restart: unless-stopped
# Networks to be created to facilitate communication between containers
networks:
fullstack:
driver: bridge
运行docker-compose up
后,我可以在localhost:5050上访问pgadmin。我可以连接到我的postgres实例。为了进行连接,我做object>create>server
。然后在“连接”选项卡中,给postgres docker容器ID进行连接:
我现在可以创建一个表,例如:
CREATE TABLE mytable(
loc_id serial PRIMARY KEY,
text VARCHAR (50) UNIQUE NOT NULL,
loc POINT NOT NULL,
time TIMESTAMP
);
正在工作。我可以将数据插入表中并进行查询。问题在pgadmin中:
感觉到pgadmin4没有正确配置。有什么解决办法的想法吗?