This post presents how to build a Docker container with compiled Mellanox DPDK PMD.
1. Install Docker version >= 1.9.
2. Install MLNX_OFED rel. 4.1-22.214.171.124 and run the ofed_info command to verify that the version is 4.1-126.96.36.199:
# ofed_info -s
Creating Docker Container Image
This section describes two equally valid procedures to generate a Docker image.
Procedure #1 - Download Dockerfile from Github and built the image locally on the hypervisor.
The benefit of this approach is that the user can modify the Dockerfile to their wish and add it some extent.
# git clone https://github.com/Amirzei/mlnx_docker_dpdk.git -b <os_version>
# cd mlnx_docker_dpdk/
# docker build --build-arg DPDK_VER=<version_number> -t ubuntu/<image_name>:<version_name> .
# docker build --build-arg DPDK_VER=17.08 -t ubuntu/mlnx_dpdk:v5 .
- <os_version> can be: ubuntu14.04 , ubuntu16.04
RHEL is not available via Dockerfile
- <image_name> and <version_name> can be any user-defined name
- The user gets the option to determine which DPDK version they would like to add and compile by specifying DPDK_VER=<version_number>
Please refer to the DPDK release notes to know which versions are supported on which OS.
Procedure #2 - Download the entire compressed image from Docker Hub.
This procedure is more strict and straightforward.
# docker pull amirzei/mlnx_docker_dpdk:<os_version>
- <os_version> can be: ubuntu14.04 , ubuntu16.04 , rhel7.2 , rhel7.3
- The DPDK default version is 17.08
Running Docker Container with Mellanox PMD
1. Define and mount hugepages on the hypervisor for a container.
Allocate 1G size of hugepages:
# echo 4 > /sys/devices/system/node/node0/hugepages/hugepages-1048576kB/nr_hugepages
OR Allocate 2Mb size of hugepages:
# echo 2048 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
# mount -t hugetlbfs -o pagesize=1G none /dev/hugepages
# mkdir -p /mnt/huge_c0
# mount -t hugetlbfs -o pagesize=1G none /mnt/huge_c0/
Note: This example exhibits allocation of 4Gb total hugepages for both 2Mb and 1Gb hugepages sizes. You may define different amounts relative to the free amount of memory on your hypervisor.
2. Define the network for the container.
The recommended type of network is SRIOV.
To view how to define an SRIOV network, please refer to the post HowTo Configure Docker in SR-IOV or Passthrough Mode with Mellanox Ethernet Adapters.
Another way is to use "host" network type. Both ways are equally valid.
3. Run a container.
Find the newly created Docker image name:
# docker image list
Run Docker image:
# docker run -itd --privileged -v /mnt/huge_c0/:/dev/hugepages/ --net=host --name=<container_name> <docker_image_name>
- This example uses net type "host". If you choose SRIOV, you must specify the SRIOV network name instead.
- DPDK libraries are located inside the container under /usr/src/dpdk-<version>/. This directory contains compiled Mellanox PMD with defaults apps such as testpmd.