To start, grab a copy of CentOS 7 from the download site. I choose the minimal ISO because there isn't much needed for this. But you can choose the any ISO you want, but it doesn't really matter which on because there is not much needed for this guide unless you need to install the OS without an internet connection. Please note, this setup will be done in VirtualBox, so some things may differ if you are setting it up on a physical machine or in VMware. Once CentOS is installed, we need to make sure we have a network connection. In VirtualBox you will need to change the network adapter to be attached to Bridged Adapter this will give the VM an IP in the same subnet as the rest of your network.
We need to install Docker first, this can be done either from a script or from the Docker repository. I chose to go with the method from the repository. Log into your machine with a super user account that has sudo or root privileges and update the existing packages. Once that has completed add the Docker repo
$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
Install the Docker package:
sudo yum install docker-engine
then start the Docker daemon:
sudo service docker start
Now that we have Docker installed, it's time to setup a script to download and run the containers needed for the NetBoot server and a directory for the NetBoot (nbi) Images. Graham describes his method of working with containers as placing the necessary files and scripts in the directory /usr/local/docker. It is his way of working and he does not suggest that it is the best, but it is nice to keep things consistent if later on down the road you setup another Docker server on your network. For this guide we are going to follow suite with creating the /usr/local/docker directory and placing the script and data there.
mkdir -p /usr/local/docker/nbi
Now it's time to start working with the startup script. In the text editor of choice, start with the first part of the script that will download the Docker containers for tftpd, netboot-httpd, and bsdpy
#!/bin/bash
docker pull macadmins/tftpd
docker pull macadmins/netboot-httpd
docker pull bruienne/bsdpy:1.0
and make it executable
chmod 755 /user/local/docker/startup.sh
then run it with the command
/usr/local/docker/startup.sh (or if you are working in the /usr/local/docker directory, you can run it with ./startup.sh
At this point, Docker should start downloading the images if everything was installed properly. Then, add a few commands after the last docker pull to stop and remove any running or installed containers. This is not necessary, but it is nice to clean up any prior installs. Also note that it doesn't take much more time to pull and start a new container than it is to start a container that was previously pulled. The benefit of this method is that you know you are running the most current version. Docker will only pull a new container if it has been changed on the Docker hub.
#stop all docker containers
docker stop $(docker ps -a -q)
#remove all docker containers
docker rm $(docker ps -a -q)
Now, to finalize the startup script with getting the server IP and running the containers previously pulled.
#change permissions on /usr/local/docker/nbi
chmod -R 777 /usr/local/docker/nbi
#set IP address as variable
IP=$(ifconfig enp0s3 | awk '/inet / {print$2}')
echo $IP
#run docker containers
docker run -d \
-v /usr/local/docker/nbi:/nbi \
--name web \
--restart=always \
-p 0.0.0.0:80:80 \
macadmins/netboot-httpd
docker run -d \
-v /usr/local/docker/nbi:/nbi \
--name tftpd \
--restart=always \
-p 0.0.0.0:69:69/udp \
macadmins/tftpd
docker run -d \
-v /usr/local/docker/nbi:/nbi \
--name bsdpy \
--restart=always \
-p 0.0.0.0:67:67/udp \
-e BSDPY_IFACE=eth0 \
-e BSDPY_NBI_URL=http://$IP \
-e BSDPY_IP=$IP \
bruienne/bsdpy:1.0
We can run the script again and at this point, if it was already run before you will notice that Docker is checking for any updates to the containers. You can verify that the containers are running with:
docker ps -a
The only thing left to do is to upload a nbi to the directory /usr/local/docker/nbi from your admin machine or a network share where your images are saved
scp -r /netboot/path/netboot.nbi root@netboothost:/usr/local/docker/nbi
Once the image has been uploaded we can restart the containers on the host with the startup script. Then check the docker logs with:
docker logs bsdpy
If everything went well you should see it found your NBI. If you want to keep the logs open while testing a deployment add -f to the command:
docker logs -f bsdpy
That's all. The NetBoot service has now been moved off the Mac Mini and onto a Linux server. Or in my case, I now have a NetBoot server to install OS X in my organization and don't have to rely on installing from USB.