Load Postgres dump after docker-compose up

后端 未结 5 1856
广开言路
广开言路 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:02

    CONTAINER_NAME="postgres"
    DB_USER=postgres
    LOCAL_DUMP_PATH="..."
    docker run --name "${CONTAINER_NAME}" postgres
    docker exec -i "${CONTAINER_NAME}" psql -U "${DB_USER}" < "${LOCAL_DUMP_PATH}"
    

提交回复
热议问题