Docker Assistance

HA user for 3 or 4 years. Initial installation via VENV and I’ve been running that way for some time. I get it, that this is no longer a recommended install and am trying to move to docker. I have never used docker and am completely ignorant. Allow me to expound on my ignorance…

I got HA running pretty quickly, but noticed that I forgot two things when I ran the initial “Docker Run” command. I’d like to add “–restart always” and the location of my usb stick “–device /dev/ttyACM0”. Can that be done after the fact?

I did “docker stop” the container and then tried to restart with " docker restart --device /dev/ttyACM --restart always home-assistant", but that’s a failure. --device not allowed.

I tried re-running “docker run”, but was told “container already in use”. I suppose I can remove the current container and rerun “docker run” with the missing parameters.

Is that the correcting action one should take? Or is there a command that would allow one to add new parameters to the container and restart?

How did I miss “Docker Update”?

By default, docker stop does not remove the container, and AFAIK, docker run expects the name to be available. Try docker restart instead.

Word of advice, look into docker-compose instead of running docker commands manually. Read up on it, you’ll find the format for docker-compose.yml files very familiar to what you do in homeassistant

Docker Compose is my next stop on the learning train. Thanks.

Running a “Portainer” container comes in very very handy, especially if you are new to docker.
I run portainer and it makes it simplier to check on container status. I use portainer for stopping and restarting containers and for deleting old images. You could also use run “docker ps” or “docker ls” to list docker containers.

There are some limitations to docker compose that I have run into. If you link containers then you have to stop them all and not just the one you want. For example I run most of my containers on a docker network to allow a reverse proxy to very easily access them. I found it cumbersome to use compose to stop just lets-encrypt without stopping home assistant. Admitting, I might be on the edge of how many containers people run for home assistant. I have about a dozen containers running to support home assistant; such as influxdb, grafana, grafana-renderer, marytts, grocy, portainer and some others. I like running things in containers vice installing on metal, it just makes it easier to backup and to update everything and you have way more control.

I maintain a document for how I configure all my containers, which is in effect a docker-compse file but I just copy and paste to command line and hit enter. This way I can add comments on things I try such as trying a beta version vice my normal stable or latest setups.

https://www.portainer.io/installation/
https://hub.docker.com/r/portainer/portainer

+1 portainer

Just stop the container and delete it. Then do the docker run with the new parameters.
However I would definitely use docker-compose. I wouldn’t use Portainer for something like this. I do use Portainer to manage my docker environment but use compose to run up and update.

Here are my opinions:

  1. Install Portainer. I use it literally for almost everything related to docker. If I want to update any container (even the HA Supervised container) I use Portainer. It’s two clicks and it’s done.

  2. I never use “–restart always”. If I need to stop the container for some reason I don’t (obviously) want it to immediately start itself back up again. I always use “–restart unless-stopped” so I have control over the containers.

  3. Don’t use Docker-compose. I’ve never seen the benefit of it if you want finer grained control of your containers. Docker-compose is a “shotgun” approach to do everything in the included containers at one time. I never want to “shotgun” an update of all containers, or a start/stop of all containers. Just use Portainer to control each container individually.

  4. Portainer can also remove containers too so you can eliminate the command line stuff if you ever need to modify the options in the container. You still need to modify and then re-run your docker run commands but at least Portainer simplifies part of it. And using the command-line on the rare occasion to rebuild your container isn’t too much of a burden. And if you create a document that contains all of the run commands for your containers it’s dead simple to update the doc with the correct/updated options and copy/paste it into the CLI to rebuild the container.

  5. Portainer can even modify the container with new options but I always find that more confusing and less straight-forward than just wiping the container and rebuilding thru the CLI.

To summarize and answer your question:

Install Portainer. Use Portainer to remove the existing container. Update the docker run command to include the new options. Run the new Docker run command to re-build the container. Done.

1 Like

I rely heavily on portainer’s compose equivalent, stacks. Using stacks, you can create compose files right there in portainer. If you need to tweak a setting, just edit your stack and redeploy.

I too run a 100% Docker installation on a clean install of Ubuntu server and do all my container management in portainer. I use compose to get portainer running on a fresh install, but then use stacks to get the rest up. Bonus feature: stacks are stored in your portainer persistent storage location as docker-compose.yml files.

maybe you can use the “duplicate” option in portainer and just make the necessary changes.

can you provide link for stacks or is this part of portainer?

Stacks are a core part of portainer. The feature is found i the side bar. Clicking add stack will bring up the stack editor. Anything that works in docker-compose 2.0 will work in a stack. Instead of managing the compose file on your own, you interact with it and deploy it through portainer.

Binding a folder to the portainer container will also give you the chance to back up your stacks, making recovery after a crash incredibly easy. Just get portainer back up and redeploy the stack.

1 Like

Lots of great ideas here! Thank you all for the input. I’m reading up on a lot of this stuff now.

Well, it looks like my comment on Portainer hijacked the tread.
It is the answer to the question but still a hijack.

Let me add, this was a very helpful discussion. Did a bunch of reading. Now I have Portainer running, great app by the way, and used the Stacks function instead of docker-compose, so it’s all in portainer. HA is up and running and I even did my first upgrade with no problem. Added MQTT (which I had running on a separate PI before), Grafana and influxdb. The latter two I have not used yet, but have meant to play with for some time. Cool stuff. Anyone looking at jumping into this pond, it was pretty straight forward.

Also used this site to cheat a bit on the compose yaml, since I’m new to the syntax: https://www.composerize.com/

Take a look around DockerHub to see what you can easily pull down. If possible I try to use builds from LinuxServer.io since they do a good job of keeping things updated.

The great thing about running docker containers is if (when) you have a HDD crash (as I am dealing with right this minute) you can rebuild your system fast as long as you copy your backups to a separate drive. My spinning 500G drive for HA died this morning; conveniently I had another 500G drive to throw in and put the system back online.

Thanks for the linuxserver.io tip.

I have a cron job running nightly to grab all the config files I change on the HA server, zip them up and dump them on another server. If my HA system dies, it should be a snap to rebuild. I’ve had to use these rescue files before (not with docker, but with VENV) and it worked well.