HA in Docker access to /usr/bin?

I’ve got HA running in Docker. I’m trying to access ‘mplayer’ for TTS but doesn’t appear it’s accessible in Docker. Is there any way to expose the certain directories to Docker so I can run shell commands?

Thanks

You can use bind-mount at container start time to exposes host’s directories to the container. The purpose however is reading/writing data, not running commands outside the container’s context.

Thanks for the reply. Is there any way to set it up so I can use shell commands? Need a script to run ‘mplayer’ which is located in /usr/bin.

You need to build a custom docker image which contains HA and mplayer. But still, the container would not have access to the host‘s audio and video hardware. Docker is about process virtualization and should communicate by network only.

Maybe you should run HA natively on the host …

I run HA in Docker and I have it setup to run shell commands on the host.

I use a procedure written up by @juan11perez and can be found here:

https://hastebin.com/sojasolite.sql

I did have to make one change to the part on copying the SSH keys (step 5) since I already had a key file on the host. If I remember correctly I had to manually copy the key into the file instead of it creating a new key file.

Hi,

This link isnt working could you share your solution please?

This is the copy I made a long time back with some notes that helped at the time:

1-Need to modify the host user privileges to skip typing your password with sudo

sudo visudo

hostuser ALL=(ALL) NOPASSWD:ALL

2-create the following directory:

$ mkdir /home/finity/docker/sshkey/.ssh

Then mount this volume in HA container to preserve the sshkey generated from the HA container and used to execute shell commands. Key will then persist through reboot or upgrades.

-v /home/hass/finity/sshkey/.ssh:/root/.ssh

3-login to container via portainer or

$ sudo docker exec -it home-assistant /bin/bash

4-generate sshkey. - https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2

$ ssh-keygen -t rsa (press enter, enter, enter)

5-copy the sshkey to your host ***

$ ssh-copy-id [email protected] (type password when prompted)

*** this won’t work if you have an existing authorized_keys file. You have to copy the key manually into the file. Put one key per line with no lines between them.

additional info from:

https://megamorphf.github.io/homeassistant/hyperion/ssh/hassio/2018/01/22/controlling-anything-via-ssh.html

https://www.cyberciti.biz/tips/linux-multiple-ssh-key-based-authentication.html

https://wiki.mcs.anl.gov/IT/index.php/SSH_Keys:authorized_keys

Thanks for this, I’ll try and solve my issue later :+1:t2: