I’m working on a project for a home webservice and I am setting up a bind9 container using docker-compose.
The issue I have encountered is from the Dockerfile directives. I need the /etc/bind directory in the container to be group owned by the ‘bind’ group and have group write permissions otherwise bind throws an error saying it cannot write and the process exits (not good).
To accomplish this I use the
RUN chown root:bind /etc/bind ; chmod g+rwx /etc/bind
directive on my Windows development machine. Ignore that I’m currently giving more than just write permissions.
Results for directory /etc/bind:
drwxrwsr-x 2 root bind 4096 Sep 18 10:08 bind
It works fine on my Windows 10 development machine. Cool. Let’s test it on my Ubuntu 20 testing machine.
I move the files over through my gitlab.
I make sure the previous test is gone:
$ docker-compose -f ns1.docker-compose.yml down
$ docker-compose -f ns1.docker-compose.yml ps # Just to be sure
I make sure all previous volumes are gone:
$ docker volume prune
$ docker volume ls # Just to be sure
Build those containers
$ docker-compose -f ns1.docker-compose.yml build
Hop into the container to check the permissions of the directory
$ docker-compose -f ns1.docker-compose.yml run bind9 /bin/bash
The permissions are equivalent as the chmod command did not even run. I don’t know why it will not run the command.
results for /etc/bind on Ubuntu 20 testing machine:
drwxr-sr-x 2 root bind 4096 Sep 18 21:44 bind
Note: The group owner is bind group indicating the first half of the RUN command worked but the second half which changes the group permissions does not work.
(EDIT: It’s also worthy of noting that I tried multiple combinations of the RUN directive within my Dockerfile:
RUN command1 && command2
RUN command1 ; command2
RUN command1
RUN command2
None have worked for command 2, not even splitting them up seperate)
Issue: The same Dockerfile produces different results on different machines with the same version of Docker.
One is Windows using Docker Desktop so I must use ‘docker compose’ vs the linux version: ‘docker-compose’
My development machine is running Windows 10 Pro Version 20H2 OS build 19042.1237
Docker version 20.10.8, build 3967b7d
Ubuntu testing machine running $ uname -a on this machine gives:
5.11.0-34-generic #36~20.04.1-Ubuntu x86_64
Docker version 20.10.8, build 3967b7d
docker-compose version 1.29.2, build 5becea4c
I’ve cut out all unnecessary files to recreate the issue and put the necessary files into their own public github repo for easy testing:
commands I use to recreate the issue on my Ubuntu 20 machine after cloning and cd’ing into repo:
make sure all previous volumes with the same name referenced in this Dockerfile are gone if you’ve run this before:
$ docker volume prune
$ docker volume ls
build from compose
$ docker-compose -f ns1.docker-compose.yml build
Run a bash to get into the container
$ docker-compose -f ns1.docker-compose.yml run bind9 /bin/bash
cd in /etc directory and ls -l and find /bin permissions:
$ cd /etc
$ ls -l
Your help in resolving this issue is much appreciated.
I think one workaround for this since the issue is from a persistent volume is to run a bash in the container with ‘-u 0’ to be root and change permissions by hand on the first run. The permission should persist and bind9 service should run fine afterwards.