我正在创建一个容器,以Podman
将 Samba Active Directory 作为主域控制器运行,并带有绑定 DNS 后端。
它基于我之前制作的一个容器,该容器具有到 Samba 和 Bind 的卷映射,并且我已经启动并运行它,但我认为它看起来有点混乱,而且当我还想备份容器内运行的 Active Directory 配置时,它会变得更加混乱。
因此,我的目标是将所有 Samba 和 Bind 相关文件移动到新位置,因此我只需要映射一个卷并创建符号链接,以便保留导航。
我的想法是使用该/srv
文件夹作为我的配置文件的根目录并创建以下符号链接结构:
/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/
除此之外,我还创建了文件夹路径,/srv/backup
因为我想将备份放在samba-tool
该文件夹中,以便 Podman 主机可以在其备份例程中获取它。
为此,我在我的文章中提出了以下几点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
以上是我的 Dockerfile 中的大部分行,但由于与问题无关,因此省略了几行。
然而。当我尝试使用 Ansible 构建容器时,在构建过程中出现以下错误:
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"}
错误代码已被格式化以便于阅读。
我确信我的 Dockerfile 中存在拼写错误,但是是什么拼写错误呢?