我必须安装hstore到我的docker postgres
这是我在shell中的普通命令来执行我的需要
psql -d template1 -c 'create extension hstore';
Run Code Online (Sandbox Code Playgroud)
如果我删除该行我的容器,它可以工作,但我自己执行hstore安装,我必须告诉我的项目中的每个人都这样做,这不是一个好的做法
这是我的 yml file
postgres:
build:
context: .
dockerfile: dockerfiles/devdb.dockerfile
environment:
POSTGRES_USER: uih
POSTGRES_PASSWORD: uIhbod!
POSTGRES_DB: uih_portal
ports:
- "5433:5432"
Run Code Online (Sandbox Code Playgroud)
这是我的docker文件 devdb.dockerfile
FROM postgres:9.5
RUN mkdir -p /var/lib/postgresql-static/data
ENV PGDATA /var/lib/postgresql-static/data
# psql -d template1 -c 'create extension hstore;'
CMD ["psql", "-d", "template1", "-c", "'create extension hstore;'"]
RUN echo "hstore extension installed"
Run Code Online (Sandbox Code Playgroud)
构建后我无法运行它
$ docker-compose up postgres
Recreating uihportal_postgres_1
Attaching to uihportal_postgres_1
postgres_1 | psql: could …Run Code Online (Sandbox Code Playgroud)