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:

  • Clustering Docker containers behind load-balancers for HA
  • Error running gitlab-ci.yml script under Alpine Docker based Image
  • Can i create log file during/after building a container
  • How to clear Docker task history
  • Using gitlab ci with docker compose leaves me with container generated folders gitlab can't remove
  • docker network - ping
  • 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

  • new docker container for every user
  • Connecting to postgres from a docker container
  • Restart docker container from another container
  • Docker Swarm + Docker Compose: running linked containers on different nodes?
  • Docker volume does not persist data
  • Docker- How to use syslog to record logs on host machine?
  • 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.