From a85474adbbca9d48e67ce10700e5f3ed2c64dfdc Mon Sep 17 00:00:00 2001 From: Gabriel Ionescu Date: Fri, 13 Oct 2017 16:01:48 +0200 Subject: Add Docker PXE installer Signed-off-by: Gabriel Ionescu Signed-off-by: Martin Borg --- nfv-installer/docker-pxe-ramboot/Dockerfile | 16 ++++++++++ nfv-installer/docker-pxe-ramboot/README | 41 ++++++++++++++++++++++++++ nfv-installer/docker-pxe-ramboot/dhcpd.conf | 6 ++++ nfv-installer/docker-pxe-ramboot/entrypoint.sh | 6 ++++ nfv-installer/docker-pxe-ramboot/pxe.cfg | 9 ++++++ 5 files changed, 78 insertions(+) create mode 100644 nfv-installer/docker-pxe-ramboot/Dockerfile create mode 100644 nfv-installer/docker-pxe-ramboot/README create mode 100644 nfv-installer/docker-pxe-ramboot/dhcpd.conf create mode 100755 nfv-installer/docker-pxe-ramboot/entrypoint.sh create mode 100644 nfv-installer/docker-pxe-ramboot/pxe.cfg diff --git a/nfv-installer/docker-pxe-ramboot/Dockerfile b/nfv-installer/docker-pxe-ramboot/Dockerfile new file mode 100644 index 0000000..f515cd3 --- /dev/null +++ b/nfv-installer/docker-pxe-ramboot/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:16.04 + +RUN apt-get update && \ + apt-get install -y isc-dhcp-server tftpd-hpa wget + +RUN touch /var/lib/dhcp/dhcpd.leases + +RUN wget http://ftp.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/netboot.tar.gz && \ + mkdir /netboot && \ + tar -zxf netboot.tar.gz -C /netboot && \ + cp /netboot/debian-installer/amd64/pxelinux.0 /var/lib/tftpboot/pxelinux.0 && \ + cp /netboot/debian-installer/amd64/boot-screens/vesamenu.c32 /var/lib/tftpboot/ + +COPY ./entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/nfv-installer/docker-pxe-ramboot/README b/nfv-installer/docker-pxe-ramboot/README new file mode 100644 index 0000000..1504968 --- /dev/null +++ b/nfv-installer/docker-pxe-ramboot/README @@ -0,0 +1,41 @@ + +This container starts a DHCP server and a TFTP server which can be used for booting boards through PXE. + +1. Build the container + - cd into this folder + - run: + docker build . -t + +2. Start a container with both the DHCP server and TFTP server configured for PXE booting: + - 4 files are needed: + - dhcpd.conf - configuration file for the DHCP server (an example is provided in the git repository) + - pxe.cfg - configuration file for the PXE server (an example is provided in the git repository) + - bzImage - kernel for the board + - rootfs.ext4 - root filesystem for the board + - Edit dhcpd.conf to match the DHCP server configuration that is needed + - Set an IP address to the interface (named INTERFACE_NAME below) where the DHCP server will be advertised on + - Run: + docker run -it --net=host --privileged \ + -v :/etc/dhcp/dhcpd.conf \ + -v :/var/lib/tftpboot/pxelinux.cfg/default \ + -v :/var/lib/tftpboot/bzImage \ + -v :/var/lib/tftpboot/rootfs.ext4 \ + + + Given that all the required files are in the current working directory and that the container is named "nfv-pxe-boot", a practical example for running on eth2 would be: + docker run -it --net=host --privileged \ + -v $(pwd)/dhcpd.conf:/etc/dhcp/dhcpd.conf \ + -v $(pwd)/pxe.cfg:/var/lib/tftpboot/pxelinux.cfg/default \ + -v $(pwd)/bzImage:/var/lib/tftpboot/bzImage \ + -v $(pwd)/rootfs.ext4:/var/lib/tftpboot/rootfs.ext4 \ + nfv-pxe-boot eth2 + + The -v parameter mounts a file specified at the left of the colon character to the destination specified at the right of the colon character. For example "-v $(pwd)/bzImage:/var/lib/tftpboot/bzImage" evaluates $(pwd)/bzImage and will map the file to /var/lib/tftpboot/bzImage in the container. + + Boot the board with network booting enabled and it should load the configuration set in pxe.cfg. + +3. Start a container with only the DHCP server running: + - Only dhcpd.conf is needed + - Set an IP address to the interface (named INTERFACE_NAME below) where the DHCP server will be advertised on + - Run: + docker run -it --net=host --privileged -v :/etc/dhcp/dhcpd.conf diff --git a/nfv-installer/docker-pxe-ramboot/dhcpd.conf b/nfv-installer/docker-pxe-ramboot/dhcpd.conf new file mode 100644 index 0000000..21df511 --- /dev/null +++ b/nfv-installer/docker-pxe-ramboot/dhcpd.conf @@ -0,0 +1,6 @@ +default-lease-time 600; +max-lease-time 7200; +subnet 192.168.1.0 netmask 255.255.255.0 { + range 192.168.1.100 192.168.1.200; + filename "/var/lib/tftpboot/pxelinux.0"; +} diff --git a/nfv-installer/docker-pxe-ramboot/entrypoint.sh b/nfv-installer/docker-pxe-ramboot/entrypoint.sh new file mode 100755 index 0000000..0930cb9 --- /dev/null +++ b/nfv-installer/docker-pxe-ramboot/entrypoint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +echo "Starting DHCP on interface: $1" + +/usr/sbin/dhcpd --no-pid $1 +nohup in.tftpd -L& +/bin/bash diff --git a/nfv-installer/docker-pxe-ramboot/pxe.cfg b/nfv-installer/docker-pxe-ramboot/pxe.cfg new file mode 100644 index 0000000..ee26ae3 --- /dev/null +++ b/nfv-installer/docker-pxe-ramboot/pxe.cfg @@ -0,0 +1,9 @@ +default vesamenu.c32 + +MENU TITLE Enea NFV Access Install +MENU COLOR title 0 #80ffffff #00000000 std + +label Run RAMFS + menu label ^Run RAMFS + kernel bzImage + append root=/dev/ram0 initrd=rootfs.ext4 ramdisk_size=2000000 console=ttyS0,115200 earlyprintk=ttyS0,115200 -- cgit v1.2.3-54-g00ecf