This took a surpising amount of digging to find… I needed to debug a command_line switch that wasn’t working as expected in hass.io so I wanted a shell on the actual environment. It’s pretty simple once you actually figure out how…
Shut down your pi and put the SD Card in your computer.
Create a file in the resinos-boot partition called authorized_keys and put your ssh public key in it.
Put the SD Card back in your pi and start it up.
Run this SSH command:
ssh -t root@hassio -p 22222 “docker exec -it \$(docker ps -f name=homeassistant -q) bash”
If you’re on windows first putty to root@hassio port 22222 then run
docker exec -it $(docker ps -f name=homeassistant -q) bash
You can substitute the name of addons where you put name=homeassistant to get into them instead. To get a full list of containers you can just run “docker ps”
UPDATE: This post was originally written with respect to resinOS hassio, newer hassio now uses HassOS. The following proceedure should still get you the same thing.
At the shell prompt you can run docker commands such as: “docker exec -it $(docker ps -f name=homeassistant -q) bash” which will get you a shell inside the homeassistant container.
Home Assistant (formerly hass.io) always has running containers, at least the supervisor container and the Home Assistant container are always running.
Can anyone provide a bit more detail on doing this via Portainer? I’m not seeing any active containers in Portainer, just a single endpoint with a certain number of images (18 for me) and some networks (4 for me).
Where should I go from here to be able to run docker commands? How do you even run a root shell from a certain container?
Edit: nevermind, figured out my problem. I didn’t even need to mess around with Portainer. I was using the official SSH and Terminal addon, which doesn’t have support for docker commands. I installed the community SSH and Web Terminal addon, and docker commands worked on the Web Interface out of the box.
Have a look at the portainer addon documentation. HA containers are hidden (for obvious and good reasons), if people know what they´re doing they can make them visible).
Hi,
I think I have a similar problem. Need to share a file with a container (Deconz plugin) since this is needed in order to make a Zigbee device update.
Where you able to access the container file system?
Remove the containers from the hidden list - as described in the Portainer addon documentation
Go to the container (only tested homeassistant)
Start console, done
It’s so easy - and quite dangerous. There’s a reason why those HA containers are hidden. People not knowing what they do could quite easily damage (parts of) their system.
I didn’t need to use Portainer. Install the COMMUNITY SSH & Web Terminal add-on (the one made by Frenk), then use docker container ls to list docker containers. Then I accessed the required container (for me it was InfluxDB) using docker exec -it 21332546_influxdb influx -username XXX -password XXX replacing 21332546_influxdb with container ID. Not sure what you would replace influx with in your situation.