Access your services from a Netbird provided mesh IP address using Docker Compose
Set the network_mode
of your netbird
container to occupy the same namespace as the service you want to expose.
Port translations using docker’s built-in networking are no longer possible with this metho. The exposed service will need to natively change its ports or an additional container for proxying can be used.
Format: service
: container_to_expose
This allows me to access the web service at something like
http://100.64.0.50:8000
Or my custom internal mesh network domain
http://splunk.signalnine.mesh:8000
Example
The magic line
network_mode: 'service:splunk'
Full Compose Project
services:
splunk:
image: splunk/splunk:latest
hostname: splunk
environment:
SPLUNK_START_ARGS: --accept-license
SPLUNK_PASSWORD: password1
SPLUNK_ENABLE_LISTEN: 9997
SPLUNK_ADD: tcp 1514
volumes:
- ./splunk_etc:/opt/splunk/etc
- ./splunk_var:/opt/splunk/var
ports:
- '8000:8000'
- '9997:9997'
- '8088:8088'
- '1514:1514'
- '3514:3514/udp'
netbird:
image: netbirdio/netbird:latest
container_name: netbird
environment:
PEER_NAME: splunk
NB_SETUP_KEY: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF
NB_MANAGEMENT_URL: https://nb.example.com
volumes:
- ./netbird_client:/etc/netbird
cap_add:
- NET_ADMIN
network_mode: 'service:splunk'
depends_on:
- splunk