stop and remove an autostart docker container

Viewed 1712

I have several containers I want to remove. When I stop them, they restart, so I can't remove them. I tried to update them with the command sudo docker update --restart=no [docker name] but they are still restarting.

Here is the output of my docker ps :

    ~$ sudo docker ps
CONTAINER ID        IMAGE                                            COMMAND                  CREATED              STATUS                PORTS                  NAMES
8482a3ba7a1c        homeassistant/amd64-hassio-dns:2021.01.0         "/init"                  About a minute ago   Up About a minute                            hassio_dns
bf6edaa5add5        homeassistant/amd64-hassio-multicast:2021.04.0   "/init"                  8 minutes ago        Up 8 minutes                                 hassio_multicast
f53752b4920f        homeassistant/amd64-hassio-audio:2021.02.1       "/init"                  8 minutes ago        Up 8 minutes                                 hassio_audio
2b5ed16c305d        homeassistant/amd64-hassio-cli:2021.03.1         "/init /bin/bash -c …"   9 minutes ago        Up 9 minutes                                 hassio_cli
27fdf9452c85        homeassistant/amd64-hassio-observer:2020.10.1    "/init"                  9 minutes ago        Up 9 minutes          0.0.0.0:4357->80/tcp   hassio_observer
612417c38db1        homeassistant/amd64-hassio-supervisor            "/init"                  6 days ago           Up 16 minutes                                hassio_supervisor

They run on a Synology NAS

2 Answers

Googling for the images you are running, it looks like you may have installed this supervised tool:

This system will run the Home Assistant Supervisor. The Supervisor is not just an application, it is a full appliance that manages the whole system. It will clean up, repair or reset settings to default if they no longer match expected values.

My reading of that is if you remove a container, this tool will probably recreate it.

Reading through the installer script, it runs:

systemctl enable hassio-apparmor.service > /dev/null 2>&1;
systemctl start hassio-apparmor.service

So to disable, try:

systemctl disable hassio-apparmor.service
systemctl stop hassio-apparmor.service

Then you can delete the containers (the -f runs an initial docker kill, this may result in data corruption of any files mounted by these containers):

docker container rm -f \
  hassio_dns \
  hassio_multicast \
  hassio_audio \
  hassio_cli \
  hassio_observer \
  hassio_supervisor

If you want to remove a container that for whatever reason is not stopping, you can simply use

docker stop <container_id> -f 

This will forcefully stop and remove your container.

Related