Thanks, this is much simpler than the original post.
Here's the equivalent Dockerfile + docker-compose.yaml for convenience:
# Dockerfile
FROM debian:11-slim
RUN apt-get -y update && apt-get -y install firefox-esr
CMD ["firefox"]
# docker-compose.yaml
services:
firefox:
image: firefox
build: .
environment:
DISPLAY: ${DISPLAY}
network_mode: host
volumes:
- ${XAUTHORITY}:/root/.Xauthority
- /tmp/.X11-unix:/tmp.X11-unix
This way you can run it with just: docker-compose up