Skip to content

Commit 69e318e

Browse files
authored
Add ONVM Dockerfile and Update Docker Resources (#38)
This change updates the docker.sh script which helps users launch NFs inside Docker containers. It removes an unncessary argument, `-w WORKINGDIRECTORY`, and changes it to launch containers based off of the new sdnfv/opennetvm Docker image. This change also provides a Dockerfile which can be used for docker image creation. It creates a docker image based off of Ubuntu 14.04 which is what is uploaded to our [Docker Hub account](https://hub.docker.com/r/sdnfv/opennetvm/). With the script changes and use of our Dockerhub account, this change also updates the Docker README in the docs directory to provide the most up-to-date information about Docker and OpenNetVM. Testing: * Launched a few containers in various topologies in Docker containers and ensured traffic flowed through the chain and latency/throughput matched what was expected when running directly on the host.
1 parent cbef283 commit 69e318e

File tree

3 files changed

+155
-127
lines changed

3 files changed

+155
-127
lines changed

docs/Docker.md

Lines changed: 48 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,44 @@
11
Running openNetVM in Docker
22
==
33

4-
To run openNetVM NFs inside Docker containers, use the
5-
included [Docker Script][docker]. This script does the following:
4+
To run openNetVM NFs inside Docker containers, use the included [Docker Script][docker]. We provide a [Docker image on Docker Hub][onvm-docker] that is a copy of [Ubuntu 14.04][ubuntu] with a few dependencies installed. This script does the following:
65

7-
- Creates a Docker container with a custom name
6+
- Creates a Docker container off of the [sdnfv/opennetvm Docker image][onvm-docker] with a custom name
87
- Maps NIC devices from the host into the container
98
- Maps the shared hugepage region into the container
109
- Maps the openNetVM directory into the container
1110
- Maps any other directories you want into the container
12-
- Configures the container to use all of the shared memory and data
13-
structures
14-
- Depending on the presence of a path or not, the container starts the NF
15-
automatically in detached mode or the terminal is connected to it to
16-
run the NF by hand
11+
- Configures the container to use all of the shared memory and data structures
12+
- Depending on the presence of a command to run, the container starts the NF automatically in detached mode or the terminal is connected to it to run the NF by hand
1713

1814
Usage
1915
--
2016

21-
To use the script, simply run it from the command line with the
22-
following options:
17+
To use the script, simply run it from the command line with the following options:
2318

24-
```
25-
sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-w WORKING DIRECTORY] [-c COMMAND]
26-
```
19+
```bash
20+
sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-c COMMAND]
21+
```
2722

2823
- `HUGEPAGES - A path to where the hugepage filesystem is on the host`
2924
- `ONVM - A path to the openNetVM directory on the host filesystem`
3025
- `NAME - A name to give the container`
31-
- `DEVICES - An optional comma deliniated list of NIC devices to map to the
32-
container`
26+
- `DEVICES - An optional comma deliniated list of NIC devices to map to the container`
3327
- `DIRECTORY - An optional additional directory to map inside the container.`
34-
- `WORKINGDIRECTORY - An optional directory in the container to be the working
35-
directory at start time. It allows a better control on the command to be run.`
36-
- `COMMAND - An optional command to run in the container. For example,
37-
the path to a go-docker script or to the executable of your NF.`
28+
- `COMMAND - An optional command to run in the container. For example, the path to a go script or to the executable of your NF.`
3829

39-
```
40-
sudo ./docker.sh -h /mnt/huge -o /root/openNetVM -n Basic_Monitor_NF
41-
-D /dev/uio0,/dev/uio1
30+
```bash
31+
sudo ./docker.sh -h /mnt/huge -o /root/openNetVM -n Basic_Monitor_NF -D /dev/uio0,/dev/uio1
4232
```
4333

44-
- This will start a container with two NIC devices mapped in, /dev/uio0
45-
and /dev/uio1, the hugepage directory at `/mnt/huge` mapped in, and the
46-
openNetVM source directory at `/root/openNetVM` mapped into the
47-
container with the name of Basic_Monitor_NF.
34+
- This will start a container with two NIC devices mapped in, /dev/uio0 and /dev/uio1, the hugepage directory at `/mnt/huge` mapped in, and the openNetVM source directory at `/root/openNetVM` mapped into the container with the name of Basic_Monitor_NF.
4835

49-
```
50-
sudo ./docker.sh -h /mnt/huge -o /root/openNetVM -n Simple_Forward_NF
51-
-D /dev/uio0 -w /openNetVM/examples/simple_forward -c "./go-docker.sh 5 1 1"
36+
```bash
37+
sudo ./docker.sh -h /mnt/huge -o /root/openNetVM -n Speed_Tester_NF -D /dev/uio0 -c "./examples/speed_tester/go.sh 5 1 1"
5238
```
5339

54-
- This will start a container with one NIC device mapped in, /dev/uio0
55-
, the hugepage directory at `/mnt/huge` mapped in, and the
56-
openNetVM source directory at `/root/openNetVM` mapped into the
57-
container with the name of Simple_Forward_NF. Also, the container will be
58-
started in detached mode (no connection to it). It will have the simple_forward
59-
subdirectory as its working directory, and it will run the go-docker script of
60-
the simple forward NF.
61-
Careful, the path needs to be correct inside the container (use absolute path,
62-
here the openNetVM directory is mapped in the /).
40+
- This will start a container with one NIC device mapped in, /dev/uio0 , the hugepage directory at `/mnt/huge` mapped in, and the openNetVM source directory at `/root/openNetVM` mapped into the container with the name of Speed_Tester_NF. Also, the container will be started in detached mode (no connection to it) and it will run the go script of the simple forward NF.
41+
Careful, the path needs to be correct inside the container (use absolute path, here the openNetVM directory is mapped in the /).
6342

6443

6544
Running NFs Inside Containers
@@ -74,48 +53,47 @@ Some prerequisites are:
7453
7554
Here is an example of starting a container and then running an NF inside of it:
7655
77-
```
78-
root@nimbnode /root/openNetVM # ./scripts/docker.sh
79-
80-
sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-w WORKINGDIRECTORY] [-c COMMAND]
81-
82-
e.g. sudo ./docker.sh -h /hugepages -o /root/openNetVM -n Basic_Monitor_NF -D /dev/uio0,/dev/uio1
83-
This will create a container with two NIC devices, uio0 and uio1,
84-
hugepages mapped from the host's /hugepage directory and openNetVM
85-
mapped from /root/openNetVM and it will name it Basic_Monitor_NF
86-
87-
root@nimbnode /root/openNetVM # ./scripts/docker.sh -h /hugepages -o /home/neel/openNetVM -n ExampleNF -D /dev/uio0,/dev/uio1
88-
root@2f20c33f9d69:/# ls
89-
bin boot dev etc home hugepages lib lib64 media mnt openNetVM opt proc root run sbin srv sys tmp usr var
90-
root@2f20c33f9d69:/# cd openNetVM/
91-
root@2f20c33f9d69:/openNetVM# ls
92-
CPPLINT.cfg LICENSE Makefile README.md docs dpdk examples onvm scripts style tags
93-
root@2f20c33f9d69:/openNetVM# cd examples/
94-
root@2f20c33f9d69:/openNetVM/examples# ls
95-
Makefile basic_monitor bridge flow_table simple_forward speed_tester test_flow_dir
96-
root@2f20c33f9d69:/openNetVM/examples# cd basic_monitor/
97-
root@2f20c33f9d69:/openNetVM/examples/basic_monitor# ls
98-
Makefile README.md basic_monitor build go.sh monitor.c
99-
root@2f20c33f9d69:/openNetVM/examples/basic_monitor# ./go.sh
56+
```bash
57+
root@nimbnode /root/openNetVM/scripts# ./docker.sh
58+
sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-c COMMAND]
59+
60+
e.g. sudo ./docker.sh -h /hugepages -o /root/openNetVM -n Basic_Monitor_NF -D /dev/uio0,/dev/uio1
61+
This will create a container with two NIC devices, uio0 and uio1,
62+
hugepages mapped from the host's /hugepage directory and openNetVM
63+
mapped from /root/openNetVM and it will name it Basic_Monitor_NF
64+
65+
root@nimbnode /root/openNetVM/scripts# ./docker.sh -h /mnt/huge -o /root/openNetVM-dev -D /dev/uio0,/dev/uio1 -n basic_monitor
66+
root@899618eaa98c:/openNetVM# ls
67+
CPPLINT.cfg LICENSE Makefile README.md cscope.out docs dpdk examples onvm onvm_web scripts style tags tools
68+
root@899618eaa98c:/openNetVM# cd examples/
69+
root@899618eaa98c:/openNetVM/examples# ls
70+
Makefile aes_decrypt aes_encrypt arp_response basic_monitor bridge flow_table flow_tracker load_balancer ndpi_stats nf_router simple_forward speed_tester test_flow_dir
71+
root@899618eaa98c:/openNetVM/examples# cd basic_monitor/
72+
root@899618eaa98c:/openNetVM/examples/basic_monitor# ls
73+
Makefile README.md build go.sh monitor.c
74+
root@899618eaa98c:/openNetVM/examples/basic_monitor# ./go.sh
10075
./go.sh CPU-LIST SERVICE-ID [-p PRINT] [-n NF-ID]
10176
./go.sh 3 0 --> core 3, Service ID 0
10277
./go.sh 3,7,9 1 --> cores 3,7, and 9 with Service ID 1
103-
./go.sh -p 1000 -n 6 3,7,9 1 --> cores 3,7, and 9 with Service ID 1 and Print Rate of 1000 and instance ID 6
104-
root@2f20c33f9d69:/openNetVM/examples/basic_monitor# ./go.sh 3 1
78+
./go.sh -p 1000 -n 6 3,7,9 1 --> cores 3,7, and 9 with Service ID 1 and
79+
Print Rate of 1000 and instance ID 6
80+
root@899618eaa98c:/openNetVM/examples/basic_monitor# ./go.sh 3 1
10581
...
10682
```
10783
108-
You can also use the optional command argument to run directly the NF inside of the container (and the optional working directory argument to have more control on the command context of execution), without connecting to it. Then, to stop gracefully the NF (so it has time to notify onvm manager), use the docker stop command before docker rm the container.
84+
You can also use the optional command argument to run directly the NF inside of the container, without connecting to it. Then, to stop gracefully the NF (so it has time to notify onvm manager), use the docker stop command before docker rm the container.
10985
The prerequisites are the same as in the case where you connect to the container.
11086
111-
```
112-
root@nimbnode /root/openNetVM # ./scripts/docker.sh -h /hugepages -o /home/adam/openNetVM -n ExampleNF -D /dev/uio0,/dev/uio1 -w /openNetVM/examples/simple_forward/ -c "./go-docker.sh 5 1 1"
87+
```bash
88+
root@nimbnode /root/openNetVM# ./scripts/docker.sh -h /mnt/huge -o /root/openNetVM -n speed_tester_nf -D /dev/uio0,/dev/uio1 -c "./examples/speed_tester/go.sh 5 1 1"
11389
14daebeba1adea581c2998eead16ff7ce7fdc45394c0cc5d6489228aad939711
114-
root@nimbnode /root/openNetVM # sudo docker stop ExampleNF
115-
ExampleNF
116-
root@nimbnode /root/openNetVM # sudo docker rm ExampleNF
117-
ExampleNF
90+
root@nimbnode /root/openNetVM# sudo docker stop speed_tester_nf
91+
speed_tester_nf
92+
root@nimbnode /root/openNetVM# sudo docker rm speed_tester_nf
93+
speed_tester_nf
11894
...
11995
```
12096
12197
[docker]: ../scripts/docker.sh
98+
[onvm-docker]: https://hub.docker.com/r/sdnfv/opennetvm/
99+
[ubuntu]: http://releases.ubuntu.com/14.04/

scripts/Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# openNetVM
2+
# https://sdnfv.github.io
3+
#
4+
# OpenNetVM is distributed under the following BSD LICENSE:
5+
#
6+
# Copyright(c)
7+
# 2015-2018 George Washington University
8+
# 2015-2018 University of California Riverside
9+
# All rights reserved.
10+
#
11+
# Redistribution and use in source and binary forms, with or without
12+
# modification, are permitted provided that the following conditions
13+
# are met:
14+
#
15+
# * Redistributions of source code must retain the above copyright
16+
# notice, this list of conditions and the following disclaimer.
17+
# * Redistributions in binary form must reproduce the above copyright
18+
# notice, this list of conditions and the following disclaimer in
19+
# the documentation and/or other materials provided with the
20+
# distribution.
21+
# * The name of the author may not be used to endorse or promote
22+
# products derived from this software without specific prior
23+
# written permission.
24+
#
25+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
37+
FROM ubuntu:14.04
38+
MAINTAINER "Neel Shah" <[email protected]>
39+
LABEL version="OpenNetVM v18.03"
40+
LABEL vendor="SDNFV @ UCR and GW"
41+
LABEL github="github.com/sdnfv/openNetVM"
42+
43+
ENV ONVM_HOME=/openNetVM
44+
ENV RTE_TARGET=x86_64-native-linuxapp-gcc
45+
ENV RTE_SDK=$ONVM_HOME/dpdk
46+
47+
WORKDIR $ONVM_HOME
48+
49+
RUN apt-get update && \
50+
apt-get install -y build-essential \
51+
gdb \
52+
libnuma-dev \
53+
vim \
54+
less \
55+
git

scripts/docker.sh

Lines changed: 52 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# OpenNetVM is distributed under the following BSD LICENSE:
77
#
88
# Copyright(c)
9-
# 2015-2017 George Washington University
10-
# 2015-2017 University of California Riverside
9+
# 2015-2018 George Washington University
10+
# 2015-2018 University of California Riverside
1111
# All rights reserved.
1212
#
1313
# Redistribution and use in source and binary forms, with or without
@@ -36,69 +36,64 @@
3636
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3737
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3838

39-
while getopts :d:w:c:D:h:o:n: option; do
40-
case $option in
41-
d)
42-
DIR=$OPTARG
43-
;;
44-
w)
45-
DWD=$OPTARG
46-
;;
47-
c)
48-
CMD=$OPTARG
49-
;;
50-
D)
51-
RAW_DEVICES=$OPTARG
52-
;;
53-
h)
54-
HUGE=$OPTARG
55-
;;
56-
o)
57-
ONVM=$OPTARG
58-
;;
59-
n)
60-
NAME=$OPTARG
61-
;;
62-
esac
39+
while getopts :d:c:D:h:o:n: OPTION ; do
40+
case ${OPTION} in
41+
d) DIR="${OPTARG}" ;;
42+
c) CMD=${OPTARG} ;;
43+
D) RAW_DEVICES=${OPTARG} ;;
44+
h) HUGE=${OPTARG} ;;
45+
o) ONVM=${OPTARG} ;;
46+
n) NAME=${OPTARG} ;;
47+
esac
6348
done
6449

6550
DEVICES=()
51+
MODE=""
6652

67-
if [ -z $NAME ] || [ -z $HUGE ] || [ -z $ONVM ]
68-
then
69-
echo -e "sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-w WORKINGDIRECTORY] [-c COMMAND]\n"
70-
echo -e "\te.g. sudo ./docker.sh -h /hugepages -o /root/openNetVM -n Basic_Monitor_NF -D /dev/uio0,/dev/uio1"
71-
echo -e "\t\tThis will create a container with two NIC devices, uio0 and uio1,"
72-
echo -e "\t\thugepages mapped from the host's /hugepage directory and openNetVM"
73-
echo -e "\t\tmapped from /root/openNetVM and it will name it Basic_Monitor_NF"
74-
exit 1
75-
fi
76-
77-
if [ -z $DWD ]
78-
then
79-
DWD="/"
53+
if [[ "${NAME}" == "" ]] || [[ "${HUGE}" == "" ]] || [[ "${ONVM}" == "" ]] ; then
54+
echo -e "sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-c COMMAND]\n"
55+
echo -e "\te.g. sudo ./docker.sh -h /hugepages -o /root/openNetVM -n Basic_Monitor_NF -D /dev/uio0,/dev/uio1"
56+
echo -e "\t\tThis will create a container with two NIC devices, uio0 and uio1,"
57+
echo -e "\t\thugepages mapped from the host's /hugepage directory and openNetVM"
58+
echo -e "\t\tmapped from /root/openNetVM and it will name it Basic_Monitor_NF"
59+
exit 1
8060
fi
8161

8262
IFS=','
83-
84-
for DEV in $RAW_DEVICES
85-
do
86-
DEVICES+=("--device=$DEV:$DEV")
63+
for DEV in ${RAW_DEVICES} ; do
64+
DEVICES+=("--device=$DEV:$DEV")
8765
done
8866

89-
if [ -z $CMD ]
90-
then
91-
if [ -z $DIR ]
92-
then
93-
sudo docker run -it --network none --privileged ${DEVICES[@]} -v /var/run:/var/run -v $HUGE:$HUGE -v $ONVM:/openNetVM -w=$DWD --name=$NAME ubuntu:14.04 /bin/bash
94-
else
95-
sudo docker run -it --network none --privileged ${DEVICES[@]} -v /var/run:/var/run -v $HUGE:$HUGE -v $ONVM:/openNetVM -v $DIR:/$(basename $DIR) -w=$DWD --name=$NAME ubuntu:14.04 /bin/bash
96-
fi
67+
if [[ "${DIR}" != "" ]] ; then
68+
DIR="--volume=${DIR}:/$(basename ${DIR})"
69+
fi
70+
71+
if [[ "${CMD}" == "" ]] ; then
72+
sudo docker run \
73+
--interactive --tty \
74+
--privileged \
75+
--name=${NAME} \
76+
--network bridge \
77+
--volume=/var/run:/var/run \
78+
--volume=${HUGE}:${HUGE} \
79+
--volume=${ONVM}:/openNetVM \
80+
${DIR} \
81+
${DEVICES[@]} \
82+
sdnfv/opennetvm \
83+
/bin/bash
9784
else
98-
if [ -z $DIR ]
99-
then
100-
sudo docker run -d=true --network none --privileged ${DEVICES[@]} -v /var/run:/var/run -v $HUGE:$HUGE -v $ONVM:/openNetVM -w=$DWD --name=$NAME ubuntu:14.04 bash -c $CMD
101-
else
102-
sudo docker run -d=true --network none --privileged ${DEVICES[@]} -v /var/run:/var/run -v $HUGE:$HUGE -v $ONVM:/openNetVM -v $DIR:/$(basename $DIR) -w=$DWD --name=$NAME ubuntu:14.04 bash -c $CMD
103-
fi
85+
sudo docker run \
86+
--detach=true \
87+
--privileged \
88+
--name=${NAME} \
89+
--network bridge \
90+
--volume=/var/run:/var/run \
91+
--volume=${HUGE}:${HUGE} \
92+
--volume=${ONVM}:/openNetVM \
93+
${DIR} \
94+
${DEVICES[@]} \
95+
sdnfv/opennetvm \
96+
/bin/bash -c "${CMD}"
10497
fi
98+
99+

0 commit comments

Comments
 (0)