Based on the documentation of Docker Postgres, I can create any *.sql file inside /docker-entrypoint-initdb.d and run it automatically.
I have init.sql which contains CREATE DATABASE ronda;
In my docker-compose.yaml I have
web: restart: always build: ./web expose: - "8000" links: - postgres:postgres volumes: - /usr/src/app/static env_file: .env command: /usr/local/bin/gunicorn ronda.wsgi:application -w 2 -b :8000 nginx: restart: always build: ./nginx/ ports: - "80:80" volumes: - /www/static volumes_from: - web links: - web:web postgres: restart: always build: ./postgres/ volumes_from: - data ports: - "5432:5432" data: restart: always build: ./postgres/ volumes: - /var/lib/postgresql command: "true"
and my postgres dockerfile,
FROM library/postgres RUN mkdir -p /docker-entrypoint-initdb.d COPY init.sql /docker-entrypoint-initdb.d/
Running docker-compose build and docker-compose up works fine, but the ronda database ronda not been created.
docker postgresql docker-compose
Shulhi sapli
source share