It turned out that AppArmor service was messing up with Docker. AppArmor (or "Application Armor") is a Linux kernel security module that allows the system administrator to restrict programs' capabilities with per-program profiles.


Dockers require a linux kernel to work, so it works like a virtual machine on Mac.

Deploying static sites in docker

Following dockerfile uses nginx:alpine image to serve static data over 8000

# nginx state for serving content
FROM nginx:1.21-alpine

# Set working directory to nginx asset directory
WORKDIR /usr/share/nginx/html

# Remove default nginx static assets
RUN rm -rf ./*

# Copy static assets over
COPY ./static ./

Build the image:

docker build -t static-serve .

Start a container

docker run -p 8000:80 static-serve

Btw, this is all an alternative to:

python -m http.server

Also see multistage builds to reduce image size, if that is a concern. See how-to-use-the-official-nginx-docker-image

For smallest possible image size for static serve, see smallest-docker-image-static-website