in Education by
I have a dump.sql file that I would like to load with docker-compose. docker-compose.yml: services: postgres: environment: POSTGRES_DB: my_db_name POSTGRES_USER: my_name POSTGRES_PASSWORD: my_password build: context: . dockerfile: ./devops/db/Dockerfile.db My Dockerfile.db is really simple at the moment: FROM postgres MAINTAINER me COPY ./devops/db ./devops/db WORKDIR ./devops/db I would like to run a command like psql my_db_name < dump.sql at some point. If I run a script like this from the Dockerfile.db, the issue is that the script is run after build but before docker-compose up, and the database is not running yet. Any idea how to do this? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
After going through the documentation https://hub.docker.com/_/postgres/ It explains that any .sql in /docker-entrypoint-initdb.d will be executed after build. For this, you just need to make small changes in Dockerfile.db FROM postgres ADD ./devops/db/dummy_dump.sql /docker-entrypoint-initdb.d This will work for your query. For more information please go through the following tutorial to get more info about docker:

Related questions

0 votes
    I have a dump.sql file that I would like to load with docker-compose. docker-compose.yml: services: postgres: ... how to do this? Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    My docker-compose file has some running docker files to create my containers. I don't want the docker files ... docker-compose syntax? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    Now that links are deprecated in docker-compose.yml (and were able to use the new networking feature to ... docker-compose.yml? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm looking for a way to configure Nginx to access hosted services through a subdomain of my server. Those services ... me with this? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    So I am trying to build a docker image with the Golang SDK, everything runs except the section in ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I have tried to build a docker image based on mono to serve a docfx documentation. Here is my ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    So I have a Nginx running inside a docker container, I have a mysql running on the host system, I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Do I need to use separate Docker containers for my complex web application or I can put all required services in ... in one container? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Can someone help me to differentiate between DevOps and Docker? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I am unable to find the containers under the directory: /var/lib/docker/containers Can you please tell me the ... the host machine? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to expose multiple ports to the machine’s interface. How to achieve this using a docker container? Please help. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have created a docker image. I want to push it into my docker repo but I am facing this error: denied: ... to the resource is denied Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I am trying to use Microsoft Power Bi to connect to a PostgreSQL database. When I go to Get Data it just ... driving me crazy! Thanks Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am trying to use Microsoft Power Bi to connect to a PostgreSQL database. When I go to Get Data it just ... driving me crazy! Thanks Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    What are the purposes of up, run, and start commands of docker compose?...
asked Jun 20, 2021 in Technology by JackTerrance
...