Reputation: 105
Here is the question, when I try to build an image with my Dockerfile:
# PostgreSQL
#
# VERSION 1.0
FROM ubuntu:12.04
VOLUME /var/lib/postgresql
# Update the packages
RUN apt-get update
RUN apt-get -y dist-upgrade
# Install PostgreSQL
RUN apt-get -y install sudo postgresql
# Configure PostgreSQL to allow logins from all networks and listen to all ip address
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.1/main/pg_hba.conf
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.1/main/postgresql.conf
EXPOSE 5432
After build the image if I try: docker run -i -t image_id /bin/bash
My /var/lib/postgresql is now empty!
Docker volumes doesn't have too much documentation so I'm really confused what's is going on.
Upvotes: 3
Views: 1450
Reputation: 121642
If you put the VOLUME instruction at the end of your Dockerfile.
Currently Docker will create a new volume for each RUN you do and therefor discard the changes.
This will get fixed soon. In the meantime, simply move your VOLUME instruction and it will do the trick :)
Upvotes: 7