这是我的docker-compose文件。有没有简单的方法来安装postgres扩展程序?我正在尝试安装pg_trgm
。
编辑:我现在有两个dockerfiles和一个安装脚本。我运行docker-compose up build
Internal server error: pq: operator does not exist: character varying % unknown
services:
db:
build:
context: .
dockerfile: db/Dockerfile
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=x
- POSTGRES_PASSWORD=x
- POSTGRES_DB=x
api:
build:
context: .
args:
app_env: ${APP_ENV}
volumes:
- .:/go/src/x/y/z
ports:
- "8080:8080"
db / Dockerfile:
FROM postgres
COPY db/install-extensions.sql /docker-entrypoint-initdb.d
db / install-extensions.sql
CREATE EXTENSION IF NOT EXISTS pg_trgm;
答案 0 :(得分:0)
尝试
FROM postgres
复制./install-extensions.sql /docker-entrypoint-initdb.d
删除数据库
或者你可以写
version: "3.1"
services:
db:
image: postgres:9.6
restart: always
environment:
POSTGRES_PASSWORD: unit
POSTGRES_USER: unit
POSTGRES_DB: unit
ports:
- 5432:5432
volumes:
- ./scripts:/docker-entrypoint-initdb.d
然后