4

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

Nidupb
  • 221
  • 3
  • 16
  • 1
    Are you providing the _container id_ or _container name_ to `docker update`? E.g `docker update --restart=no 8482a3ba7a1c` to update the running `homeassistant/amd64-hassio-dns` container's restart policy. – Jeroen van der Laan Apr 11 '21 at 20:13
  • `docker rm -f ` might do the trick. If this still doesn't work, since you are on synology, you might simlpy want to use the GUI. – Zeitounator Apr 11 '21 at 21:42
  • How were they started? – BMitch Apr 11 '21 at 23:07
  • None of this works :( I installed them through ssh following a tutorial that I didn't keep. I don't have them in the gui. Containers keeps restarting with all the described method. – Nidupb Apr 11 '21 at 23:22
  • Maybe, your containers are managing by Docker Swarm which is ensure that service running. – huytmb Apr 15 '21 at 00:53
  • @huytmb that was my first thought, but the container names don't have the extensions added by swarm mode. – BMitch Apr 16 '21 at 01:44

2 Answers2

2

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
BMitch
  • 231,797
  • 42
  • 475
  • 450
  • Unfortunately, the output of the systemctl command on the synology is : ` ~$ systemctl disable hassio-apparmor.service` `-sh: systemctl: command not found` – Nidupb Apr 16 '21 at 01:10
  • @Nidupb were you root? If that doesn't help, you're going to need to find how you installed these containers to sort out how to uninstall them, because something external is recreating them, from the description, it's not docker itself. Your googling to find it will be better than ours. – BMitch Apr 16 '21 at 01:48
  • alternative to systemctl try like this, "service hassio-apparmor stop" – KumailR Apr 21 '21 at 06:24
0

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

docker rm <container_id> -f 

This will forcefully stop and remove your container.

EdwardKirk
  • 425
  • 1
  • 7
  • 16