Update
Note that I have added another answer after I have found out what the root cause was in my case: Concurrent docker installations
I recommend that you check if that is the case for you, too, because if so, the other answer provides the preferred solution.
This answer helped me with docker as well:
After
sudo aa-remove-unknown
the problem was instantly gone and docker stop
would work again as expected. See: aa-remove-unknown – remove unknown AppArmor profiles
Background
As far as I understand it, the problem cause is that the docker package does not install a profile for docker in the AppArmor service, so docker is categorized as ‘unknown’ by AppArmor. The above command removes the profile for all unknown applications, so they are no longer restricted by AppArmor.
Of course, the correct way would be to keep the profile for unknown applications and create an AppArmor profile for docker. According to the docker docs on AppArmor security profiles for Docker, “A profile for the Docker Engine daemon exists but it is not currently installed”.