所以,我有一个具有这种结构的 docker-compose 项目:
DockerDev
- docker-compose.yaml
- d-php
- Dockerfile
- scripts-apache
- d-postgresql
- Dockerfile
- scripts
- dev_data_setup.sql
- logs
- pgdata
- www
PHP、Redis、ElasticSearch 都可以。但是 Postgresql 没有运行 dev_data_setup.sql,我发现/dockes-entrypoint-initdb.d 有任何不同的解决方案(卷、添加、复制等)。我试图运行和 sh 脚本,什么都没有。
你能看到这个 docker-compose 和 Dockerfile 并帮助我吗?谢谢
Dockerfile:
FROM postgres:latest
ADD ./scripts/dev_data_setup.sql /docker-entrypoint-initdb.d
docker-compose.yaml:
version: '2'
services:
php:
build: ./d-php/
hostname: www.domain.com
ports:
- "80:80"
volumes:
- ./www:/var/www/html
- ./d-php/scripts-apache2/apache2.conf:/etc/apache2/apache2.conf
- ./d-php/scripts-apache2/web.conf:/etc/apache2/sites-enabled/web.conf
- ./d-php/scripts-apache2/webservice.conf:/etc/apache2/sites-enabled/webservice.conf
- ./logs:/var/log/apache2
links:
- db
- redis
- elasticsearch
db:
build: ./d-postgresql/
volumes:
- ./pgdata:/pgdata
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- PGDATA=/pgdata
redis:
image: redis:latest
elasticsearch:
image: elasticsearch:2.4.1
最佳答案
所以我发现了问题。
- 首先:我的 sql 脚本试图重新创建 postgres 用户。然后,dockedev_db 退出了。
- 第二:我需要删除所有与 db 相关的图像,以便 docker-compose 再次运行脚本。
感谢您的帮助。
关于postgresql - Docker PostgreSQL-/docker-entrypoint-initdb.d 中的脚本不运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40386221/