# Minimal case to illustrate Docker+Postgres issue # i.e.: did not manage to make the Postgres data persistent when using volumes in docker-compose. # Derived from my normal Docker development image (itself modeled after Heroku's production environment for the stack.) # # Let's keep it minimal. FROM ubuntu:16.04 # Avoid Dialog and other interactive features not suited to Dockerfiles ENV DEBIAN_FRONTEND noninteractive # Update and configure packages # Installing apt-utils to avoid `debconf: delaying package configuration, since apt-utils is not installed` warning when installing programs (except for `apt-utils` itself.) RUN apt-get update RUN apt-get install -y --no-install-recommends apt-utils # Install Postgres # Should I install `postgresql-contrib` too? suffixed -9.6? RUN apt-get install -y software-properties-common RUN add-apt-repository -y "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" RUN apt-get install -y wget RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add RUN apt-get update RUN apt-get install -y postgresql-9.6 ENV PATH="${PATH}:/usr/lib/postgresql/9.6/bin" RUN mkdir -p /var/run/postgresql/9.6-main.pg_stat_tmp && chown postgres.postgres /var/run/postgresql/9.6-main.pg_stat_tmp -R # Prevents `could not open temporary statistics file` error # VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] # I thought this might be needed, but it's not. # Install supervisor # (We add its config file much later, as it depends on the other installed programs and is likely to change. # This way, we spare ourselves reinstalling things that didn't change when building the image.) RUN apt-get install -y supervisor # Entry point for when the image starts ADD supervisord.conf /etc/ CMD ["/usr/bin/supervisord"] ## MEMO. # # BUILD THE IMAGE LIKE SO: # cd /Users/fabien/Dropbox/DEV/Docker/images/minicase-postgres # docker build -t fab/minicase-postgres . # Use `--no-cache` if needed: `docker build --no-cache -t fab/minicase-postgres .` # # START THE IMAGE VIA DOCKER TO CHECK IT OUT: # docker run --name myminicase -dit fab/minicase-postgres # docker exec -it myminicase /bin/bash