Django test database fails in circleci

docker

#1

I have a Django Postgres project that I am deploying with docker-compose, it runs and all the test pass in every environment, but the tests for some reason fail in circleci. There is some issue with django creating a test database that seems to fail in circleci and I don’t know enough about circleci and docker to resolve.

# circle.yml
machine:
  services:
    - docker

dependencies:
  pre:
    - pip install docker-compose

test:
  pre:
    - docker-compose up -d
  override:
    - docker-compose run web python manage.py test

error in circleci:

django.db.utils.OperationalError: FATAL:  no pg_hba.conf entry for host "172.18.0.4", user "docker", database "postgres", SSL on
FATAL:  no pg_hba.conf entry for host "172.18.0.4", user "docker", database "postgres", SSL off

docker-compose:

web:
  container_name: web
  restart: always
  build: ./web
  expose:
    - "8000"
  links:
    - postgres:postgres
  volumes:
    - /usr/src/app
    - /usr/src/app/static
  env_file: .env
  environment:
    DEBUG: 'true'
  command: ./startup.sh
postgres:
  restart: always
  image: kartoza/postgis:9.4-2.1
  ports:
    - "5432"
  volumes:
    - pgdata:/var/lib/postgresql/data/

#2