Skip to content

Scripts in /docker-entrypoint-initdb.d doesn't run #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rodrigosaraiva opened this issue Nov 2, 2016 · 2 comments
Closed

Scripts in /docker-entrypoint-initdb.d doesn't run #215

rodrigosaraiva opened this issue Nov 2, 2016 · 2 comments

Comments

@rodrigosaraiva
Copy link

So, I have a docker-compose project with this structure:

DockerDev
- docker-compose.yaml
- d-php
  - Dockerfile
  - scripts-apache
- d-postgresql
  - Dockerfile
  - scripts
    - dev_data_setup.sql
- logs
- pgdata
- www

PHP, Redis, ElasticSearch is OK. But Postgresql doesn't run dev_data_setup.sql, with any diferent solutions to /dockes-entrypoint-initdb.d that I found (volume, ADD, COPY, etc). I tried to run and sh script and nothing.

Could you see this docker-compose and Dockerfile and help me? Thanks

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
@tianon
Copy link
Member

tianon commented Nov 7, 2016

@rodrigosaraiva I'm guessing you've discovered it for yourself, but docker-compose works very hard to ensure that your volumes are persisted between recreations of the containers, so you likely had a pre-initialized database in your postgres container which was then re-used, causing your SQL script to not be executed

@yosifkit
Copy link
Member

yosifkit commented Nov 7, 2016

For future reference : #203 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants