Load Postgres dump after docker-compose up

后端 未结 5 1841
广开言路
广开言路 2021-02-02 12:42

I have a dump.sql file that I would like to load with docker-compose.

docker-compose.yml:

services:
  postgres:
    environment:
      POSTGRES_DB: my_d         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 13:06

    Reading https://hub.docker.com/_/postgres/, the section 'Extend this image' explains that any .sql in /docker-entrypoint-initdb.d will be executed after build.

    I just needed to change my Dockerfile.db to:

    FROM postgres
    
    ADD ./devops/db/dummy_dump.sql /docker-entrypoint-initdb.d
    

    And it works!

提交回复
热议问题