I'm trying to use FIG ( http://www.fig.sh/ ) 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:
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
ENV PYTHONUNBUFFERED 1
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:
db:
image: postgres
ports:
- 5432
web:
build: .
command: python manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
links:
- db
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:
Dockerfile
FROM postgres
ADD . /files
WORKDIR /files
RUN /etc/init.d/postgresql start && \
pg_restore -d DBNAME < backup.sql && \
/etc/init.d/postgresql stop
fig.yml
db:
build: dockerfiles/db
Now when you run any fig commands your database should be ready to go
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.