Overview
Docker containers can be used on the Operations Manager to run customized applications, pre-built apps such as iPerf and for automation use cases such as ZTP. The Operations Manager has a fully featured version Docker built into each device. Building and running Docker containers on the Operations Manager is no different than running Docker in any other Linux environment. Users can leverage the more than one million containers hosted on Docker hub for internet connected Operations Managers.
Example
Below is an example of how to deploy an ISC DHCP server Docker container on the Operations Manager. The steps assume the Operations Manager has a connection to the internet or can reach Docker Hub (https://hub.docker.com). Creating a container consists of building the image, creating the container from the image, and running the container.
Building the Docker image
1. Create a directory called dhcpd on the Operations Manager (e.g. /home/root/dhcpd).
2. Create a file called Dockerfile in the directory you created in Step 1 (e.g. /home/root/dhcpd/Dockerfile). Edit the file Dockerfile with the contents in the below code block.
FROM alpine:latest
RUN apk update && apk add \
dhcp \
&& rm -rf /var/cache/apk/*
3. Build a Docker image from the Dockerfile created in Step 2 by entering in the below command.
sudo docker build -t opengear:dhcpd .
You will see the image download. Successfully building the image will have the below output.
root@om1208:~/dhcpd# sudo docker build -t opengear:dhcpd .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM alpine:latest
latest: Pulling from library/alpine
8921db27df28: Pull complete
Digest: sha256:f271e74b17ced29b915d351685fd4644785c6d1559dd1f2d4189a5e851ef753a
Status: Downloaded newer image for alpine:latest
---> 042a816809aa
Step 2/2 : RUN apk update && apk add dhcp && rm -rf /var/cache/apk/*
---> Running in bb3ea09a5f11
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/community/x86_64/APKINDEX.tar.gz
v3.17.1-149-g025d6c73a4 [https://dl-cdn.alpinelinux.org/alpine/v3.17/main]
v3.17.1-154-g2c0a1adfdf [https://dl-cdn.alpinelinux.org/alpine/v3.17/community]
OK: 17813 distinct packages available
(1/3) Installing libgcc (12.2.1_git20220924-r4)
(2/3) Installing dhcp (4.4.3_p1-r1)
Executing dhcp-4.4.3_p1-r1.pre-install
(3/3) Installing dhcp-server-vanilla (4.4.3_p1-r1)
Executing busybox-1.35.0-r29.trigger
OK: 12 MiB in 18 packages
Removing intermediate container bb3ea09a5f11
---> f7016f260771
Successfully built f7016f260771
Successfully tagged opengear:dhcpd
You can verify the image is loaded on the Operations manager by issuing the below command.
docker images -a
The output:
root@om1208:~/dhcpd# docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
opengear dhcpd f7016f260771 3 minutes ago 12.1MB
alpine latest 042a816809aa 3 weeks ago 7.05MB
Creating and running the DHCP server container
1. As root or sudo, create directory /etc/dhcp on the Operations Manager.
sudo mkdir /etc/dhcp
2. Create file dhcpd.conf in the directory created in Step 4 (/etc/dhcp/dhcpd.conf). Add the below contents (edit to match your environment, below is a sample DHCP server config).
# Sample /etc/dhcpd.conf # (add your comments here) default-lease-time 600; max-lease-time 7200; option subnet-mask 255.255.255.0; option broadcast-address 10.11.0.255; option routers 10.11.0.1; option domain-name-servers 1.1.1.1, 8.8.8.8; option domain-name "mydomain.example"; subnet 10.11.0.0 netmask 255.255.255.0 { range 10.11.0.10 10.11.0.100; }
Note: The subnet should match a subnet on your Operations Manager.
3. Create directory /var/lib/dhcp on your Operations Manager.
sudo mkdir /var/lib/dhcp
4. Create file dhcpd.leases in the the directory you created in Step 3.
sudo touch /var/lib/dhcp/dhcpd.leases
5. Use the docker run command to build and start the container. The container will map the directories /etc/dhcp and /var/lib/dhcp to the container.
sudo docker run \
--name dhcp \
-itd \
--net host \
-v /etc/dhcp:/etc/dhcp \
-v /var/lib/dhcp:/var/lib/dhcp \
opengear:dhcpd \
/bin/sh
6. Verify the container is running the below command.
sudo docker ps -a
Output:
root@om1208:~/dhcp# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9c60d3d7c01d opengear:dhcpd "/bin/sh" 4 seconds ago Up 3 seconds dhcp
7. Start the the DHCP server in the container.
sudo docker exec dhcp dhcpd
8. Verify that the DHCP server is running in the container.
sudo docker exec dhcp ps -a | grep dhcp
Output:
root@om1208:~/dhcp# sudo docker exec dhcp ps -a | grep dhcpd
18 root 0:00 dhcpd
9. Optional: Use the docker stop command to stop the DHCP container.
sudo docker stop dhcp
You should have a fully function DHCP server running in a container on your Operations Manager!
Helpful Links
Docker Basics - https://developer.fedoraproject.org/tools/docker/docker-usage.html
ISC DHCP - https://www.isc.org/dhcp/
ISC DHCP Configuration Example - https://help.ubuntu.com/community/isc-dhcp-server
Pre-built DHCP Container - https://github.com/opengear/om-docker-dhcpd
Comments
0 comments
Article is closed for comments.