Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Docker to Ubuntu 18 #202

Merged
merged 8 commits into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 80 additions & 2 deletions docs/Docker.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Running openNetVM in Docker
==

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:
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 18.04][ubuntu] with a few dependencies installed. This script does the following:

- Creates a Docker container off of the [sdnfv/opennetvm Docker image][onvm-docker] with a custom name
- Maps NIC devices from the host into the container
Expand Down Expand Up @@ -40,6 +40,25 @@ sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-c CO
- 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.
Careful, the path needs to be correct inside the container (use absolute path, here the openNetVM directory is mapped in the /).

To remove all containers
```bash
sudo docker rm $(sudo docker ps -aq)
```

To remove all docker images from the system
```bash
# list all images
sudo docker images -a

# remove specific image
sudo docker rmi <IMAGE ID>

# clean up resources not associated with running container
docker system prune

# clean up all resources
docker system prune -a
```

Running NFs Inside Containers
--
Expand All @@ -62,7 +81,7 @@ sudo ./docker.sh -h HUGEPAGES -o ONVM -n NAME [-D DEVICES] [-d DIRECTORY] [-c CO
hugepages mapped from the host's /hugepage directory and openNetVM
mapped from /root/openNetVM and it will name it Basic_Monitor_NF

root@nimbnode /root/openNetVM/scripts# ./docker.sh -h /mnt/huge -o /root/openNetVM-dev -D /dev/uio0,/dev/uio1 -n basic_monitor
root@nimbnode /root/openNetVM/scripts# ./docker.sh -h /mnt/huge -o /root/openNetVM -D /dev/uio0,/dev/uio1 -n basic_monitor
root@899618eaa98c:/openNetVM# ls
CPPLINT.cfg LICENSE Makefile README.md cscope.out docs dpdk examples onvm onvm_web scripts style tags tools
root@899618eaa98c:/openNetVM# cd examples/
Expand All @@ -88,6 +107,65 @@ speed_tester_nf
...
```

Setting Up and Updating Dockerfiles
--

If you need to update the Dockerfile in the future, you will need to follow these steps.

```bash
# install docker fully
sudo curl -sSL https://get.docker.com/ | sh
```

Make an update to `scripts/Dockerfile`. Create an image from the new Dockerfile.

```bash
# run inside scripts/
docker image build -t sdnfv/opennetvm:<some ID tag> - < ./Dockerfile
```
This command may take a while as it grabs the Ubuntu container, and installs dependencies.
Test that the container built correctly. Go into `scripts/docker.sh` and temporarily change line 84

```vim
# from this
sdnfv/opennetvm \
# to this
sdnfv/opennetvm:<some ID tag> \
```

Make sure it is the same tag as the build command. This stops docker from pulling the real `sdnfv/opennetvm`

Test what you need to for the update and remove all containers.
```bash
sudo docker rm $(sudo docker ps -aq)
```

Create an account on Docker online and sign via CLI:
```bash
sudo docker login -u <username> docker.io
```

Make sure you are apart of the sdnfv Docker organization:
```bash
# push updated image
docker push sdnfv/opennetvm

# rename to update latest as well
docker tag sdnfv/opennetvm:<some ID tag> sdnfv/opennetvm
docker push sdnfv/opennetvm:latest
```

Now the image is updated, and will be the default next time someone pulls.

Older Dockerfiles
--

If you want to use an older ONVM version on Ubuntu 14, take a look at the [Available Tags][onvm-docker-tags].
The 18.03 tag runs ONVM when it had been set up for an older version of Ubuntu.
The `latest` dockerfile runs on Ubuntu 18.04 and is called `latest`.

[docker]: ../scripts/docker.sh
[onvm-docker]: https://hub.docker.com/r/sdnfv/opennetvm/
[onvm-docker-tags]: https://hub.docker.com/r/sdnfv/opennetvm/tags
[ubuntu]: http://releases.ubuntu.com/14.04/

6 changes: 2 additions & 4 deletions examples/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ if [ ! -f ../start_nf.sh ]; then
exit 1
fi

SCRIPT=$(readlink -f "$0")
MANAGER_PATH=$(dirname "$(dirname "$SCRIPT")")

if [[ -z $(pgrep -u root -f "$MANAGER_PATH/onvm/onvm_mgr/$RTE_TARGET/onvm_mgr") ]]
# only check for running manager if not in Docker
if [[ -z $(pgrep -u root -f "/onvm/onvm_mgr/.*/onvm_mgr") ]] && ! grep -q "docker" /proc/1/cgroup
then
echo "NF cannot start without a running manager"
exit 1
Expand Down
3 changes: 2 additions & 1 deletion onvm/go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ verbosity=1
# Initialize base virtual address to empty.
virt_addr=""

if [[ -n $(pgrep -u root -f "$SCRIPTPATH/onvm_mgr/$RTE_TARGET/onvm_mgr") ]]
# only check for duplicate manager if not in Docker container
if [[ -n $(pgrep -u root -f "/onvm_mgr/.*/onvm_mgr") ]] && ! grep -q "docker" /proc/1/cgroup
then
echo "Manager cannot be started while another is running"
exit 1
Expand Down
14 changes: 9 additions & 5 deletions scripts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,26 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

FROM ubuntu:14.04
MAINTAINER "Neel Shah" <neel@shah7.com>
LABEL version="OpenNetVM v18.03"
FROM ubuntu:18.04
MAINTAINER "Kevin Deems" <kevin8deems@gmail.com>
LABEL version="OpenNetVM v19.07"
LABEL vendor="SDNFV @ UCR and GW"
LABEL github="github.com/sdnfv/openNetVM"

ENV ONVM_HOME=/openNetVM
ENV RTE_TARGET=x86_64-native-linuxapp-gcc
ENV RTE_SDK=$ONVM_HOME/dpdk
ENV ONVM_NUM_HUGEPAGES=1024

WORKDIR $ONVM_HOME

RUN apt-get update && \
RUN apt-get update -y && apt-get upgrade -y && \
apt-get install -y build-essential \
sudo \
gdb \
python \
libnuma-dev \
vim \
less \
git
git \
net-tools \
3 changes: 3 additions & 0 deletions scripts/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ if [[ "${DIR}" != "" ]] ; then
DIR="--volume=${DIR}:/$(basename "${DIR}")"
fi

# warn users about go script ignoring manager checks
echo "Please ensure the manager is running before starting dockerized NFs"

#shellcheck disable=SC2086
if [[ "${CMD}" == "" ]] ; then
sudo docker run \
Expand Down