I am using docker-compose to create docker image combining postgresql and python application using the database.
I want to run several sql init scripts when I start the container. For this I am using volumes specified in docker-compose.yml (at the last line of the file):
version: '3.6'
services:
parking_lots_app:
build: .
depends_on:
- parking_lots_db
environment:
STAGE: test
networks:
- default
ports:
- 5000:5000
restart: always
parking_lots_db:
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: 123456
image: kartoza/postgis
networks:
- default
ports:
- 5432:5432
restart: always
volumes:
- ./postgresql/:/docker-entrypoint-initdb.d/
The problem is these init scripts are only run the first time I run docker-compose up. When I tried it on different machine it again worked for the first time, but second time it did not run the scripts.
I tried removing all containers, images, volumes on the machine. I tried rebooting and restarting docker. I tried changing the name of the directory with the sql scripts to something different than "postgresql". Nothing seems to help.
I am running Gentoo-5.4.38.
Does anyone have a clue, what's wrong? I've been struggling for far too long.
Thanks
docker-compose up -d --build
rebuilds the container and reruns the scripts in /docker-entrypoint-initdb.d/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With