How restore a postgres database with fig?

I’m trying to use FIG ( for a django app. I can’t recreate the database from a dump, I try:

fig run db pg_restore -d DBNAME < backup.sql

And get:

  • Crontab doesn't have credentials
  • how to build and run android apk on emulator using dockerfile
  • service discovery in docker without using consul
  • docker for mac failed to start
  • Chokidar isn't picking up file changes inside docker container
  • Simple docker containers: Build dedicated image or mount config as volume?
  • socket.error: [Errno 104] Connection reset by peer

    But this run (still not see the tables in the db):

    fig run db pg_restore < backup.sql

    This is the dockerfile:

    FROM python:3.4
    RUN mkdir /code
    WORKDIR /code
    ADD requirements.txt /code/
    ADD backup.sql /code/
    RUN pip install -r requirements.txt
    RUN pg_restore -d postgres  backup.sql
    ADD . /code/

    And fig.yml:

      image: postgres
        - 5432  
      build: .
      command: python runserver
        - .:/code
        - "8000:8000"
        - db

  • How to get the mapped port on host from a docker container?
  • Postgres docker-image won't run and won't start [closed]
  • TLS verification issue when setting up remote docker interpreter in pycharm in Windows
  • cron job not running inside docker container on ubuntu
  • Docker with a Rails App-Workers not running
  • How can I change the docker id and name
  • One Solution collect form web for “How restore a postgres database with fig?”

    When you run

    fig run db pg_restore -d DBNAME < backup.sql

    postgresd is not running. You’ve replaced the startup of the daemon with the pg_restore command.

    I would suggest doing something like this:

    1. Move backup.sql to dockerfiles/db/backup.sql
    2. Create a dockerfiles/db/Dockerfile
    3. change your fig.yml to use build for the db instead


    FROM postgres
    ADD . /files
    WORKDIR /files
    RUN /etc/init.d/postgresql start && \
        pg_restore -d DBNAME < backup.sql && \
        /etc/init.d/postgresql stop


        build: dockerfiles/db

    Now when you run any fig commands your database should be ready to go

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.