I am using docker home assistant on ubuntu 18.04.
I want to execute a bash script through my host that access the docker container and executes a script.
I want the script to toggle a Sonoff device on and off.
However I am not sure what should be inside toggleLight.sh.
I will then attach this command to a keyboard shortcut on my server so that I can remotely without a laptop or a phone toggle the lights on and off using a remote keyboard if available.
How can I make toggleLight.sh communicate with HA to actually toggle the light?
Have a look at this command line utility, I have used it for a while successfully and I believe it will allow you to meet your requirements. It runs from any where you can access Home Assistant via a browser inside your network as it uses same web api calls, you do not run it from within the HA container environment:
I understand the HA command you describe to only work with the Home Assistant operating system type setup. The command I described works from any machine on network that can connect to a Home Assistant server no matter what type of HA install you are doing.