coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
26.24k stars 1.33k forks source link

[Feature]: option for using the host network #1092

Open otahirs opened 1 year ago

otahirs commented 1 year ago

Is there an existing issue for this?

Summary

Add option to bind the container directly to the host network. equal to the docker run --network host ...

ps: this option would bypass the coolify proxy, it is expected there is a custom reverse proxy setup (e.g. nginx) or that the port is meant to be directly exposed to the internet

Why should this be worked on?

In network heavy application the docker bridge network can become the main performance bottleneck.

maxexcloo commented 1 month ago

Having the same issue here - was there any fix?

matheusfillipe commented 1 week ago

With the default installation and using caddy, the internal web apps only see the docker bridge address. I was able to get it working for the web apps by adding network_mode: host and removing the network block because they are not compatible together In the proxy server config:

version: '3.8'
services:
  caddy:
    container_name: coolify-proxy
    image: 'lucaslorentz/caddy-docker-proxy:2.8-alpine'
    restart: unless-stopped
    network_mode: host
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    environment:
      - CADDY_DOCKER_POLLING_INTERVAL=5s
      - CADDY_DOCKER_CADDYFILE_PATH=/dynamic/Caddyfile
    networks:
      - coolify
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock:ro'
      - '/data/coolify/proxy/caddy/dynamic:/dynamic'
      - '/data/coolify/proxy/caddy/config:/config'
      - '/data/coolify/proxy/caddy/data:/data'

Now my web apps can see the real IP but this breaks access to the main coolify app itself (still have it on port 8000). Why is that so?

{
  "level": "error",
  "ts": 1717660262.7968147,
  "logger": "http.log.error",
  "msg": "dial tcp: lookup coolify-realtime on 127.0.0.53:53: server misbehaving",
  "request": {
     ...,
  }
  "duration": 0.001383811,
  "status": 502,
  "err_id": "ie0vnxi7e",
  "err_trace": "reverseproxy.statusError (reverseproxy.go:1267)"
}

For having this on non http apps, would be ideal to support --network host here https://coolify.io/docs/knowledge-base/docker/custom-commands