Shell commands from docker container

Heya! I’m new to HA and automation in general. Looking for some advice on how to tackle this.

I have an Raspberry pi running HA in a docker container. I’m trying to make an on/off switch for my pc and got the WoL part working. Turning off less so.

Right now I’m trying to send a shell command from the docker container to the static ip from the pc, but it does not seem to be working. Entering the command ‘plainly’ into the RPI’s terminal does work however.

Right now i have this:

Switch:
 platform: wake_on_lan
 mac: [MACADRESS] 
 turn_off:
   service: shell_command.shutdown

shell_command:
 shutdown: "net rpc shutdown -I [IPADRESS] -U [LOGIN]"

Any idea on how to successfully get this message across from within the container?

Enable debug logging for shell_command and test again. It will give you more detail on what is going wrong in the system log.

Go to developer tools > services

service: logger.set_level
data:
  homeassistant.components.shell_command: debug

Make sure to reset after testing.

The OS running on the rpi running Debian and the OS running in the docker container are going to be different. I’m willing to bet that the net binary is not available in the container os. When you use the shell_command from HA, it’s using the container OS.

I’m honestly not sure you could add the binaries required to do this. If you exec into the container (docker exec [container] -it), you should be able to see if your command executes there. But, I’m willing to bet it won’t.

Hello, I was looking for answer to the same question and found good suggestions in this post https://community.home-assistant.io/t/shell-commands-in-docker-container/32180