Advertisement
Guest User

Dockerfile (minicase postgres)

a guest
Aug 2nd, 2017
491
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. # Minimal case to illustrate Docker+Postgres issue
  2. # i.e.: did not manage to make the Postgres data persistent when using volumes in docker-compose.
  3. # Derived from my normal Docker development image (itself modeled after Heroku's production environment for the stack.)
  4. #
  5. # Let's keep it minimal.
  6.  
  7. FROM ubuntu:16.04
  8.  
  9.  
  10. # Avoid Dialog and other interactive features not suited to Dockerfiles
  11. ENV DEBIAN_FRONTEND noninteractive
  12.  
  13.  
  14. # Update and configure packages
  15. # Installing apt-utils to avoid `debconf: delaying package configuration, since apt-utils is not installed` warning when installing programs (except for `apt-utils` itself.)
  16. RUN apt-get update
  17. RUN apt-get install -y --no-install-recommends apt-utils
  18.  
  19.  
  20. # Install Postgres
  21. # Should I install `postgresql-contrib` too? suffixed -9.6?
  22. RUN apt-get install -y software-properties-common
  23. RUN add-apt-repository -y "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
  24. RUN apt-get install -y wget
  25. RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add
  26. RUN apt-get update
  27. RUN apt-get install -y postgresql-9.6
  28. ENV PATH="${PATH}:/usr/lib/postgresql/9.6/bin"
  29. 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
  30. # VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] # I thought this might be needed, but it's not.
  31.  
  32.  
  33. # Install supervisor
  34. # (We add its config file much later, as it depends on the other installed programs and is likely to change.
  35. # This way, we spare ourselves reinstalling things that didn't change when building the image.)
  36. RUN apt-get install -y supervisor
  37.  
  38.  
  39.  
  40.  
  41.  
  42. # Entry point for when the image starts
  43. ADD supervisord.conf /etc/
  44. CMD ["/usr/bin/supervisord"]
  45.  
  46.  
  47.  
  48.  
  49.  
  50. ## MEMO.
  51. #
  52. # BUILD THE IMAGE LIKE SO:
  53. # cd /Users/fabien/Dropbox/DEV/Docker/images/minicase-postgres
  54. # docker build -t fab/minicase-postgres .
  55. # Use `--no-cache` if needed: `docker build --no-cache -t fab/minicase-postgres .`
  56. #
  57. # START THE IMAGE VIA DOCKER TO CHECK IT OUT:
  58. # docker run --name myminicase -dit fab/minicase-postgres
  59. # docker exec -it myminicase /bin/bash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement