There are a couple of other options you can consider to send the WoL packet outside of the docker private network if you don't want to expose the container to the host network using the already mentioned --network host
approach.
The first option is to specify the network you want to broadcast to (i.e., 192.168.1.0/24
), and use the corresponding broadcast address to send the packet, like this:
$ wakeonlan -i 192.168.1.255 aa:bb:cc:dd:ee:ff
Sending magic packet to 192.168.1.255:9 with aa:bb:cc:dd:ee:ff
The requirement for this method to work is the docker network adapter must be configured for the broadcast (see this article for more details).
The other option is easier, and the only requirement is your target machine has a static IP. In that case, you can specify the IP and MAC address and don't need to do any specific configuration to the docker network.
$ wakeonlan -i 192.168.1.10 aa:bb:cc:dd:ee:ff
Sending magic packet to 192.168.1.10:9 with aa:bb:cc:dd:ee:ff
Note: wakeonlan
uses port 9
by default, but it's not used in any case so you can use whatever port you prefer. You will see programs using 7
, 4000
, or other ports. 7
for me it's cleaner because it's usually a Discard service, but it's really not important.
--net=host
? – Sosthina--net=host
to use the host's LAN. – Sosthina--net=host
does not work on a mac and silently will not work as expected. github.com/docker/for-mac/issues/2716 – Hitherto