Docker on Debian

Hello. I am trying to get the network working within Docker containers running on Debian (this is a new thread, I have an old one lying around). I saw through other posts and did a lot of googling and one thing seemed to fix the problem: Removing AppArmor. But, I guess that’s not a good solution. So I tried to compare the AppArmor versions running on Ubuntu with Debian.

I found out that the AppArmor package running on Debian is too old. I’m aware that packages on Debian sometimes have not-so-newer versions, but I think, with Apparmor, it’s way too old. Below you can see the Apparmor versions running on Ubuntu and Debian.

On Ubuntu Jammy:

sudo dpkg --list | grep apparmor
ii  apparmor                        3.0.4-2ubuntu2.1                        amd64        user-space parser utility for AppArmor
ii  libapparmor1:amd64              3.0.4-2ubuntu2.1                        amd64        changehat AppArmor library

On Debian 11:

sudo dpkg --list | grep apparmor
ii  libapparmor1:amd64         2.13.6-10                    amd64        changehat AppArmor library

Is that causing the problem?


Some more information. Here is the output when I try to spin up an Nginx container.

admin@debdocker:~$ docker run -p 80:80 nginx:alpine
/ /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/ Looking for shell scripts in /docker-entrypoint.d/
/ Launching /docker-entrypoint.d/ info: Getting the checksum of /etc/nginx/conf.d/default.conf info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/ Launching /docker-entrypoint.d/
/ Launching /docker-entrypoint.d/
/ Configuration complete; ready for start up
2022/07/20 15:09:24 [emerg] 1#1: socket() failed (13: Permission denied)
nginx: [emerg] socket() failed (13: Permission denied)

Why can the container bind to port 80? Nothing else is running on port 80 (checked with netstat) and I’ve added myself into the "docker " group to run docker as a non-root user. Only by passing “–privileged” the container could bind to port 80. If this is caused by AppArmor, what do I need to do?