I am setting up a Jenkins master inside a Docker container. The container runs on an Ubuntu 16.04 host, which itself is a virtual machine.
We use NIS for authentication in Jenkins, but I cannot get the NIS client to run in the container. In my Dockerfile I replicated the instructions for setting up NIS on Ubuntu:
FROM jenkins
MAINTAINER John McGehee
# The base image set USER to jenkins
USER root
# Change user jenkins uid:pid from 1000:1000 to 7000:7000
RUN groupmod --gid 7000 jenkins
RUN usermod --gid 7000 --uid 7000 jenkins
# Make user jenkins more convenient
RUN mkdir -p /home/jenkins
run chown jenkins:jenkins /home/jenkins
RUN usermod --home /home/jenkins --shell /bin/bash jenkins --comment "Jenkins via Docker"
# Add user jenkins to group shadow so it can use NIS authentication
RUN usermod --groups shadow jenkins
# Set up NIS clients per https://help.ubuntu.com/community/SettingUpNISHowTo
RUN echo '10.10.10.11 infra1 infra1.wavesemi.com infra1.wavecomp.com' >> /etc/hosts
RUN echo '10.10.10.12 infra2 infra2.wavesemi.com infra2.wavecomp.com' >> /etc/hosts
RUN apt-get update
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get install --yes portmap nis
RUN echo 'wavesemi.com' > /etc/defaultdomain
RUN echo 'portmap : 10.10.10.11' >> /etc/hosts.allow
RUN echo 'portmap : 10.10.10.12' >> /etc/hosts.allow
RUN echo '+::::::' >> /etc/passwd
RUN echo '+:::' >> /etc/group
RUN echo '+::::::::' >> /etc/shadow
RUN echo 'ypserver infra1' >> /etc/yp.conf
RUN systemctl start nis
# Run user jenkins in container
USER jenkins
Then I ran the Dockerfile:
sudo docker build -t myjenkins .
The command RUN systemctl start nis
gives the error:
Failed to get D-Bus connection: Unknown error -1
The command '/bin/sh -c systemctl start nis' returned a non-zero code: 1
but the rest of the Dockerfile runs successfully.
When I start the container, it knows only user jenkins
, as defined in the container's /etc/passwd
.