Docker Community Forums

Share and learn in the Docker community.

Compose file with host mode on

Hi
I want to use Host Mode networking. How do I configure that in my compose file?
Here is my situation.

  1. Django container
  2. Database.
    I want Django container use my OSX postgres on port 5432. And I will apply my case to production.
    It is Ubuntu 14.04 postgres on port 5432 as well

Here is my simplified compose file

---

version: '2'
services:

  backend:
    build:
      context: .
      dockerfile: dockerfiles/backend_dev
    image: 703402649386.dkr.ecr.ap-southeast-1.amazonaws.com/clhm-ops-web:backend
    command: ["sh", "backend_dev.sh"]
    volumes:
      - 'frontend_output:/frontend_output'
      - 'cdmop_media:/www/data/media'
      - 'cdmop_static:/www/data/static'
    links:
      - postgres
      - frontend
      - redis
      - rq_worker_a
      - rqscheduler
    ports:
      - "80:80"
    restart: "always"
    environment:
      DJANGO_SETTINGS_MODULE: cdmop.config.settings.local
      DATABASE_URL: postgres://cdmop:password@postgres:5432/cdmop
      DJANGO_MEDIA_ROOT: /www/data/media
      DJANGO_STATIC_ROOT: /www/data/static
      REDIS_HOST: redis
      REDIS_PORT: 6379
      FRONTEND_OUTPUT: /frontend_output


...

network_mode: "host"

but on OS-X it might not work as expected.

Thank you. I have not found that page when I was searching for an example