I’m encountering an issue when trying to run a Docker container with a custom user and bind mounts. I’m using a custom Docker image that includes the BIND DNS server (“named”) and a specific configuration for it. The goal is to run the BIND server inside the container with non-root permissions and bind mount a directory from the host into the container.
However, when I run the container using the following command:
docker run --user $(id -u):$(id -g) -it --name dns-primary -p 8053:53/udp -v /home/deyan/DEV/DockerTryes/MyImage:/etc/bind dns-primary
My host system: Ubuntu 22.04.3 LTS
Docker version 24.0.6, build ed223bc
I use custom Dockerfile and here it is:
GNU nano 6.2 Dockerfile *
1 # Use Ubuntu as the base image
2 FROM ubuntu
3
4 # Install BIND DNS server
5 RUN apt-get update && apt-get install -y bind9
6
7 # With or without this its the same :
8 # Set the correct permissions for the /etc/bind directory
9 # RUN chown -R 1000:1000 /etc/bind
10
11 # Expose DNS port
12 EXPOSE 53/udp
13
14 # Start BIND when the container runs
15 CMD [“/usr/sbin/named”, “-g”, “-u”, “bind”]
16
I’m puzzled by this error, as I’ve tried several permissions configurations, and the user running Docker has ownership of the mounted configurations.
Could someone please help me understand why I’m getting this “setgid permission denied” error and how to resolve it? Any guidance or suggestions would be greatly appreciated.
Thank you!