Wake On LAN from a container
This is a simple solution that provides wake on lan capabilities from inside a container. It uses the simple awake
command to send the magic packet. This can be incredibly helpful if you just need a simple button to click to wake up a machine on your network.
Docker containers will normally use a docker network, which is a separate network from the host network. This means that the container will not be able to send the magic packet to the host network. Therefore, we need to create the container with the --network host
option, which will allow the container to send the magic packet to the host network (not the docker network).
The container is also created with the --user root
option, which allows the container to send the magic packet as root. This is necessary because the awake
command requires root privileges to send the magic packet, and also to install the awake
command in the container.
Create the container as follows;
user@host: docker create -u root --network=host --name olivetin_wol -v /etc/OliveTin/:/config ghcr.io/olivetin/olivetin:latest
Create your OliveTin config.yaml
file in the /etc/OliveTin/
directory on the host, with the following content;
actions:
- title: WakeOnLan Server1
shell: awake A8:5E:45:E4:FF:2A
icon: ping
- title: Install awake on startup
shell: microdnf install -y awake
hidden: true
execOnStartup: true
timeout: 120
Obviously adjust the config file with your own MAC addressses, creating new actions to send WOL commands as needed.
Then start the container with the following command;
docker start olivetin_wol
Then visit your OliveTin web interface at http://yourServer:1337 and you should see something that looks like this;
![wol](images/wol.png)