Hi - I’ve been beating my head against this for 2 days, and it’s hurting, I’m sure I’m missing something fundamental, and simple, but I can’t see it.
I need a containerise an existing service. The service needs to be able to send and receive unicast and broadcast UDP messages to/from network devices (the devices are black boxes to me, I can’t change how they operate). The devices send broadcast messages to 255.255.255.255 when they start up, and when certain trigger actions occur - they send unicast messages to any client that requests data.
So, my custom service sends “poll” messages to 10.255.255.255 periodically, requesting a response from any devices that are listening. My service listens to 0.0.0.0, so receives the broadcast and unicast messages, it works fine when running outside a container
From my digging around, I need a “macvlan” network, the container will pretend it’s a standalone network device and everything will be peaches. Except that it doesn’t - the container seems to only
Here’s my docker_compose:
version: '3.2'
services:
device-info-service:
image: device-info-service
container_name: device-info-service
restart: always
stdin_open: true
ports:
- 7001:7001/udp
volumes:
- ./data:/var/local/data
networks:
local_lan:
ipv4_address: "10.10.1.17"
mac_address: "02:00:00:00:00:01"
networks:
local_lan:
driver: macvlan
driver_opts:
parent: wlp0s20f3
ipam:
config:
- subnet: "10.0.0.0/8"
gateway: "10.0.0.1"
aux_addresses:
host1: "10.10.1.13"
here’s what “docker inspect device-info-service_local_lan” tells me:
[
{
"Name": "device-info-service_local_lan",
"Id": "415c438dbcf9eced334c56aa6c767fab0bded7d4bc2ceb4109eeaf59f7bdb0eb",
"Created": "2024-03-27T17:25:57.459002205+11:00",
"Scope": "local",
"Driver": "macvlan",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "10.0.0.0/8",
"Gateway": "10.0.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"ae277d4f217f441a61bfc750af0bce422fd4480052b8a4a124d972e39fa39fde": {
"Name": "device-info-service",
"EndpointID": "63888116a98fb777e9268aba52ff77d63e729b52c6cb1a1ad4847c83c4a74ef7",
"MacAddress": "02:00:00:00:00:01",
"IPv4Address": "10.10.1.17/8",
"IPv6Address": ""
}
},
"Options": {
"parent": "wlp0s20f3"
},
"Labels": {
"com.docker.compose.network": "local_lan",
"com.docker.compose.project": "device-info-service",
"com.docker.compose.version": "2.17.3"
}
}
]
looks good?
but inside the container, it still has an IP from the bridge network, and any UDP messages, either broadcast or unicast only go over the docker0 network interface.
getting into the container shell with “docker run -it --entrypoint /bin/bash device-info-service” gives me:
root@2c97a4aedce0:/usr/share/event-manager# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.3 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:ac:11:00:03 txqueuelen 0 (Ethernet)
RX packets 10 bytes 1132 (1.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@2c97a4aedce0:/usr/share/event-manager#
any help?