Host Network for Containers running in Docker Swarm - CloudCommandos/JohnChan GitHub Wiki

Example docker-compose.yaml
cadvisor is configured to use host network.

version: "3.8"
services:
  node-exporter:
    image: registry.4gms.com:5443/node-exporter:v1.0.1
    ports:
    - "${node_exporter_HTTP_PORT}:9100"
    environment:
      - DEPLOYMENT_ENV=${DEPLOYMENT_ENV}

  cadvisor:
    image: registry.4gms.com:5443/cadvisor:v0.32.0
    environment:
      - DEPLOYMENT_ENV=${DEPLOYMENT_ENV}
    volumes:
    - /:/rootfs:ro
    - /var/run:/var/run:rw
    - /sys:/sys:ro
    - /var/lib/docker:/var/lib/docker:ro
    networks:
      - host

networks:
  host:
    external: true

Do not define ports for the container that uses host network. Otherwise it will fail silently.