1

I am creating a container for Podman that runs Samba Active Directory as a Primary Domain Controller and with Bind DNS backend.

It is based of a previous container that I made which had volume mappings to both Samba and Bind and that I have gotten up and running, but I thought it looked a bit messy and would become even more messy when I also wanted to have to backup of running Active Directory config inside the container.

My goal is therefore to move the all Samba and Bind related files to a new location, so I only have to map one volume and make symlinks so navigation is preserved.

My idea is to use the /srv folder as the root for my configuration files and make following symlink structure:

/etc/krb5.keytab -> /srv/conf/etc/krb5.keytab
/etc/krb5.conf   -> /srv/conf/etc/krb5.conf
/etc/bind/       -> /srv/conf/etc/bind/
/etc/samba/      -> /srv/conf/etc/samba/
/var/lib/samba/  -> /srv/conf/lib/

On top of that I also made the folder path /srv/backup due to I want to place backups from samba-tool to land in that folder as it can be picked up by Podman host as part of its backup routine.

To that end I have amongst others the following lines in my Dockerfile:

# Use Ubuntu 22.04 LTS as base for my container
FROM ubuntu:jammy

ENV DEBIAN_FRONTEND noninteractive

# Avoid ERROR: invoke-rc.d: policy-rc.d denied execution of start.
RUN echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d

# Try creating a single mount point
VOLUME ["/srv"]

# Setup ssh and install supervisord
RUN apt-get update
RUN apt-get upgrade -y

# Install bind9 dns server
RUN apt-get install -y bind9 dnsutils

# Add customized Bind options to default bind install location.
# Note: 
# Assume Dockerfile is placed at /workdir/Dockerfile
#
# Then "etc/bind/named.conf.options" is placed at 
# /workdir/etc/bind/named.conf.options
# 
# The second argument is where should the file be placed 
# inside the countainer.
ADD etc/bind/named.conf.options /etc/bind/named.conf.options

# Install samba and dependencies to make it an Active Directory Domain Controller
RUN apt-get install -y samba smbclient winbind libpam-winbind libnss-winbind krb5-kdc libpam-krb5

# Skipping a bit of the Dockerfile here, since it is not relevant 
# for the question.
#

# Create backup dir that is being used by samba-tool 
# inside the container to store backups of samba.
RUN mkdir -p /srv/backup

# Create folder for all files in /etc folder that 
# can be modified during running of container. 
# 
# The '-p' argument creates any missing parent folder, like
# if /etc/conf does not exist it will created at the same time as
# /etc/conf/etc folder.

RUN mkdir -p /srv/conf/etc

# Move configuration of Bind and Samba to a folder that can be 
# saved between reboots.
RUN mv /etc/bind /srv/conf/etc/
RUN mv /etc/samba /srv/conf/etc/

# Add symlinks so Bind and Samba configuration can be accessed 
# from /etc folder
RUN ln -s /srv/conf/etc/bind /etc/bind
RUN ln -s /srv/conf/etc/samba /etc/samba

# Add folder for Samba lib files than can be saved between reboots.
RUN mkdir -p /srv/conf/lib

# Move Samba lib files to the new lib folder.
RUN mv /var/lib/samba/* /srv/conf/lib/

# Delete old lib folder as the folder name 'samba' was not moved. 
RUN rm /var/lib/samba/'

# Make symlink so Samba lib files can be access via /var/lib/samba
RUN ln -s /srv/conf/lib /var/lib/samba

The above is most of the lines in my Dockerfile, though a few lines have been omitted, due to not being relevant for question.

However. When I try to build the container by using Ansible I get the following error during build:

fatal: [buildserver.example.com]: FAILED! => {"changed": false, "msg": "Failed to build
image samba-ad2:latest:  

mv: cannot move '/etc/bind' to '/srv/conf/etc/': No such file or directory
Error: error building at STEP \"RUN mv /etc/bind /srv/conf/etc/\": 

error while running runtime: exit status 1\n"}

Error code has been formatted for readability.

I am certain that I am making typos in my Dockerfile, but what typos?

  • Can you explain what you trying with these lines `RUN mv /etc/bind /srv/conf/etc/` and `RUN mv /etc/samba /srv/conf/etc/` what are the source and destination? – asktyagi Sep 02 '22 at 10:05
  • Sure. See: https://docs.docker.com/engine/reference/builder/#run. `Dockerfile` is not a shell script, so if I want to run a Linux command inside Dockerfile, then I have to put the command `RUN` in front of it. The syntax of the move command is `mv source destination`. A quick explanation of containers. They are basically a small OS installations with the special ability that content inside them cannot change between reboots - except for whatever files you have placed in special volumes which is the `/srv` folder in my case. – Lasse Michael Mølgaard Sep 02 '22 at 10:50
  • My intent to ask these details is `mv: cannot move '/etc/bind' to '/srv/conf/etc/': No such file or directory` mean either `/etc/bind` or `/srv/conf/etc/` doesn't exist. Can you add output to show these folder in your question? – asktyagi Sep 02 '22 at 10:53
  • They do exist. You can assume I have installed Bind further up in my Dockerfile via `apt-get install bind` its default install location is `/etc/bind`. The path `/srv/conf/etc/` also exists as it is created in the second command listed in my except from `Dockerfile`. – Lasse Michael Mølgaard Sep 02 '22 at 10:57
  • It might be a bug https://github.com/containers/buildah/issues/4221 – Erik Sjölund Sep 06 '22 at 09:47

0 Answers0