qoomon / docker-host

A docker sidecar container to forward all traffic to local docker host or any other host
MIT License
1.1k stars 88 forks source link

Cant find dockerhost #29

Closed jpkontreras closed 4 years ago

jpkontreras commented 4 years ago

Hello I want to connect to a postgres DB on my local machine through a container im using docker compose v3

docker-compose.yml

version: '3.5'

services:
  dockerhost:
    build:
      context: ../
      dockerfile: ./docker/files/host.dockerfile
    cap_add:
      - NET_ADMIN
      - NET_RAW
    restart: on-failure
    networks:
      - backend
  backend_app:
    container_name: agenda_api_app_dev
    build:
      context: ../
      dockerfile: ./docker/files/app.dockerfile
    volumes:
      - ../:/var/www/
    networks:
      - backend
    depends_on:
      - dockerhost
  backend_server:
    container_name: agenda_api_server_dev
    build:
      context: ..
      dockerfile: ./docker/files/server.dockerfile
    volumes:
      - ../public:/var/www/public
      - ../storage/logs/:/var/log/nginx
    ports:
      - ${APP_PORT}:80
    depends_on:
      - backend_app
    networks:
      - backend
networks:
  backend:
    driver: bridge

host.dockerfile

FROM qoomon/docker-host:latest

When executed shows dockerhost as unknown . What it could be ?

Captura de Pantalla 2020-03-11 a la(s) 14 48 30

Im active if you want more info

jpkontreras commented 4 years ago

OS : mac OS 10.14.4 mojave

qoomon commented 4 years ago

my first guess would be that your application tries to connect before the docker-host container is started. depends_on will only ensure that the dependen container will be started but it does not ensure that the service is available.

qoomon commented 4 years ago

you may can try to start th.e dockhost service first with a seperate command e.g.

docker-compose up dockerhost and than docker-compose up to ramp-up the rest.

jpkontreras commented 4 years ago

I will try that. I'll let you know Thanks

jpkontreras commented 4 years ago

tried the solution but the result is the same Some questions

qoomon commented 4 years ago

the host address is always the service name itself in your case dockerhost