Cookiecutter-django: Postgres image not creating role or editing the pg_hba.conf file

Created on 1 Jul 2017  路  4Comments  路  Source: pydanny/cookiecutter-django

This problem happened randomly, no files changed same vanilla template generated from cookie cutter.
than after trying to get the image up i get these error,

Creating network "apple_default" with the default driver
Creating apple_node_1 ... 
Creating apple_postgres_1 ... 
Creating apple_node_1
Creating apple_postgres_1

Creating apple_postgres_1 ... done

Creating apple_node_1 ... done
Creating apple_django_1 ... 
Creating apple_django_1

Creating apple_django_1 ... done
Attaching to apple_postgres_1, apple_node_1, apple_django_1
postgres_1  | LOG:  database system was interrupted; last known up at 2017-07-01 02:29:07 UTC
django_1    | Postgres is unavailable - sleeping
node_1      | [02:30:01] Using gulpfile /app/gulpfile.js
postgres_1  | LOG:  database system was not properly shut down; automatic recovery in progress
node_1      | [02:30:01] Starting 'default'...
postgres_1  | LOG:  invalid record length at 0/14EE5F0: wanted 24, got 0
postgres_1  | LOG:  redo is not required
postgres_1  | LOG:  MultiXact member wraparound protections are now enabled
postgres_1  | LOG:  database system is ready to accept connections
node_1      | [02:30:01] Starting 'build'...
postgres_1  | LOG:  autovacuum launcher started
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
node_1      | [02:30:01] Starting 'images'...
node_1      | [02:30:01] Starting 'favicons-images'...
node_1      | [02:30:01] Starting 'nonfavicons-images'...
node_1      | [02:30:01] Starting 'scripts'...
node_1      | [02:30:01] Starting 'js-scripts'...
node_1      | [02:30:01] Starting 'styles'...
node_1      | [02:30:01] Starting 'sass-styles'...
node_1      | [02:30:01] Finished 'styles' after 1.24 ms
node_1      | [02:30:01] Finished 'scripts' after 3.55 ms
node_1      | [02:30:01] Finished 'images' after 12 ms
node_1      | [02:30:01] Finished 'build' after 13 ms
node_1      | [02:30:01] Starting 'init-browserSync'...
node_1      | [02:30:01] Finished 'init-browserSync' after 8.28 ms
node_1      | [02:30:01] Starting 'watch'...
node_1      | [02:30:01] Finished 'watch' after 14 ms
node_1      | [02:30:01] Finished 'default' after 36 ms
node_1      | [02:30:01] Finished 'favicons-images' after 38 ms
node_1      | [02:30:01] gulp-imagemin: Minified 0 images
node_1      | [02:30:01] Finished 'nonfavicons-images' after 63 ms
node_1      | [02:30:01] Finished 'js-scripts' after 60 ms
node_1      | [02:30:01] Finished 'sass-styles' after 58 ms
node_1      | [02:30:01] Starting 'css-styles'...
node_1      | [BS] Reloading Browsers...
node_1      | [02:30:01] Starting 'styles'...
node_1      | [02:30:01] Starting 'sass-styles'...
node_1      | [02:30:01] Finished 'styles' after 723 渭s
node_1      | [BS] Copy the following snippet into your website, just before the closing </body> tag
node_1      | <script id="__bs_script__">//<![CDATA[
node_1      |     document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.js?v=2.18.12'><\/script>".replace("HOST", location.hostname));
node_1      | //]]></script>
node_1      | 
node_1      | [BS] Access URLs:
node_1      |  ----------------------------------
node_1      |           UI: http://localhost:3001
node_1      |  ----------------------------------
node_1      |  UI External: http://localhost:3001
node_1      |  ----------------------------------
node_1      | [02:30:01] Finished 'css-styles' after 104 ms
node_1      | [02:30:01] Finished 'sass-styles' after 21 ms
node_1      | [02:30:01] Starting 'css-styles'...
node_1      | [02:30:01] Finished 'css-styles' after 8 ms
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
postgres_1  | FATAL:  no pg_hba.conf entry for host "172.19.0.4", user "apple", database "apple", SSL off
django_1    | Postgres is unavailable - sleeping
Stopping apple_django_1 ... 
Stopping apple_postgres_1 ... 
Stopping apple_node_1 ... 
Killing apple_django_1 ... 
Killing apple_postgres_1 ... 
Killing apple_node_1 ... 

Killing apple_django_1 ... done

Killing apple_postgres_1 ... done

Killing apple_node_1 ... done
Gracefully stopping... (press Ctrl+C again to force)

So i entered a shell on the running postgres image and edited the pg_hba.conf file
and added 0.0.0.0/0
Than after that error went away and i was left with this error
apple role doesn't exist.. im confused, so I tried deleting the postgres image and the error persists.

Most helpful comment

Ok I figured it out.
turns out i needed to prune my volumes with
docker volume prune

All 4 comments

This is the docker file im using

version: '2'

volumes:
  postgres_data_dev: {}
  postgres_backup_dev: {}

services:
  postgres:
    build: ./compose/postgres
    volumes:
      - postgres_data_dev:/var/lib/postgresql/data
      - postgres_backup_dev:/backups
    environment:
      - POSTGRES_USER=apple

  django:
    build:
      context: .
      dockerfile: ./compose/django/Dockerfile-dev
    command: /start-dev.sh
    depends_on:
      - postgres
      - node
    environment:
      - POSTGRES_USER=apple
      - USE_DOCKER=yes
    volumes:
      - .:/app
    ports:
      - "8000:8000"





  node:
    build:
      context: .
      dockerfile: ./compose/node/Dockerfile-dev
    volumes:
      - .:/app
      # http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html
      - /app/node_modules
    command: "gulp"
    ports:
      # BrowserSync port.
      - "3000:3000"
      # BrowserSync UI port.
      - "3001:3001"

I have an update:
I have run the command
docker run --name some-postgres -e POSTGRES_USER=apple -e POSTGRES_PASSWORD=secretpassword postgres:9.6
and that does create the role for user apple.

weird, I deleted the image that the docker file created for postgres, re-build it and now instead of giving me the error about the hba file, it just tells me that the role doesn't exist. This is the most inconsistent behavior that i have seen from docker. considering that i have made no changes on the docker file.

Ok I figured it out.
turns out i needed to prune my volumes with
docker volume prune

Was this page helpful?
0 / 5 - 0 ratings