Can not stop Docker Container: permission denied Error

I was using testcontainer with localstack. After failing test, it doesn’t clean up the container it made.
Then when I tried to kill containers, this error came up. I was so pissed off…
But you saved me. Thank you very much @jsloan117 !!
Ubuntu18

You made my day. Thank you so much

Thank you… worked instantly!

Excelente fuciona en ubuntu 18.1

@ jsloan117 Understanding that your proposed solution remediates the error, doesn’t it also reduce the security of the system and address only the symptom rather than the disease?

i.e. disabling AppAmor prevents the error from reoccurring but doesn’t address the cause of the error.

1 Like

Don’t follow this command :warning:

Greatly helpful advice. It has uninstalled Snap and all of the software I’ve had installed over Snap including Docker, IDE, GNOME (!) and like 40 other apps. It has done severe damage to my Ubuntu Desktop instance.

1 Like

:frowning: Be careful with old answers and everything that deletes something if you don’t know what the result is.

I know it doesn’t help you but in case of a service like apparmor it is enough to stop and disable the service

systemctl stop apparmor
systemctl disable apparmor

I also had bad experience with the autoremove feature years ago but in the most cases it shouldn’t do any harm.

I hope the damage is not irreversible.

It’s true, Several applications are uninstalled…But it fixes the problem, it even fixed the problem I had with docker permissions.

:warning: :warning: :warning: :warning: :warning: This comment is criminal ! Don’t follow this !!! It will erase all your apps :rage:

2 Likes

Correct, it had me very scared!

Just update Docker

As of now, the problem seems to re-emerge with potentially a recent Docker version.

Updating Docker in my case seemed to fix the problem.

In my case the route to this was

snap refresh docker --beta

The resulting/working snap is

$ snap list docker

Name    Version   Rev   Tracking     Publisher   Notes
docker  20.10.12  1690  latest/beta  canonical✓  -

As far as I can tell I don’t have it via apt (can’t remove it as it’s not installed), you may need to get there by apt remove docker or similar (UPDATE: See the reply below - it can be a bad idea to switch to a snapped Docker. My main point is to rather try updating Docker - whether via apt or snap - than to remove your AppArmor. Much rather :slight_smile: )

Good luck everyone!

I know this topic is not about Docker installation, but I would not recommend installing Docker from snap repository. I understand that it seems easier, but you can (but not necessarily will) have more problems later. Use the recommended way by the Documentation depending on which distribution you use.

Use snap only if your distribution is somehow not supported by Docker and yet it is supported by snap.

2 Likes

That can be right, thanks! I don’t really know that (it’s a local Docker for me mainly for testing, so being 1-2 versions behind is acceptable + I also have a vested interest in seeing how well snaps perform in practice, as I try to maintain one whilst considering a format change primarily in favour of flatpak).

I think there may be some utility in addressing the snap route as they’re now offered via Ubuntu Software Center - which might be the reason for some people experiencing this issue with less edgy Docker versions (which then justifies both of our replies to some degree :slight_smile:).

The key I guess is to try switching to a different Docker version.

As an excuse, the reason for my hasty yet unknowledgeable reply was the malicious suggestion making a comeback elsewhere (Error response from daemon: Cannot kill container: permission denied, how to kill docker containers on Ubuntu 20.04? - Stack Overflow).
Hopefully nobody has experienced a data loss, my snap may not be that well-behaved (I think it partly is, but not necessarily to 100%) - may not be the only one.

F** you dude, this removed all my essentials app, including snap, pycharm, rubymine and many other snap-installled apps.

1 Like

Sorry for resurecting this zombie thread but I found a better solution (at least in my case). The problem was not that apparmor was doing something inappropriate but that the Snap version of Docker was being used/preferred over the apt version. To resolve this, I verified that I had a valid, installed version from apt with apt search docker-ce and then removed the Snap version:

sudo snap remove --purge docker

After a reboot, the problem was solved.

2 Likes

Wow this was the trick for me when nothing above worked at all… I don’t remember even trying to install docker via snap but turns out there was something there when remove purge docker was used… anyway upon reboot I have full control over my containers and a proper APT-installed version of docker. Saving this solution for future installations!! Thank you for this!!