Using docker-compose to create tables in postgresql database

后端 未结 3 1783
渐次进展
渐次进展 2020-12-23 01:59

I am using docker-compose to deploy a multicontainer python Flask web application. I\'m having difficulty understanding how to create tables in the postgresql database durin

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-23 02:46

    It didn't work for me with the COPY approach in Dockerfile. But I managed to run my init.sql file by adding the following to docker-compose.yml:

        volumes:
            - ./init.sql:/docker-entrypoint-initdb.d/init.sql
    

    init.sql was in the same catalog as my docker-compose.yml. I picked the solution from here.

提交回复
热议问题