I’m writing some code for dealing with DHCP leases and in order to test that, I would like to connect two docker containers on a private network that can communicate with each other on UDP ports 67 and 68.
So basically one container with DHCP client functionality and another container running a DHCP server daemon.
I have made it work by having a docker-compose.yml file containing (basically):
services: dhcpd: image: networkboot/dhcpd:latest container_name: dhcpd ports: - 67:67/udp networks: - privnet dhcp_client: build: dhcp_client container_name: dhcp_client ports: - 68:68/udp networks: privnet: ipam: config: - subnet: 192.168.0.0/24
But that means that port 67 and 68 gets exposed on the host as well which I definitely do not want.
I have tried using
expose to simply expose the ports as well as linking the containers, but then the containers are not able to communicate with each other through these ports.
I feel like there’s something very basic that I’m missing, or is it simply not possible to achieve what I want?
Thanks a lot.