How to build Mellanox DPDK PMD image on top Docker

Version 7

    This post demonstrate quick approach on how to build Docker container with compiled Mellanox DPDK PMD.

     

     

    References

    Hypervisor prerequisite

    1. Install Docker version >= 1.9.

     

    2. Install MLNX_OFED rel. 4.1-1.0.2.0  and use the ofed_info command to verify that the version is 4.1-1.0.2.0:

    # ofed_info -s

     

    Creating Docker container image

    This section will describe two procedures equally match on how to generate a Docker image.

    User can choose which suits him the most.

     

    1. First Procedure - Download Dockerfile from github and built the image locally on the hypervisor.

    The benefit of this approach is the user can modify the Dockerfile to his 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> .

    Example:
    # docker build --build-arg DPDK_VER=17.08 -t ubuntu/mlnx_dpdk:v5 .

     

    Notes:

    • <os_version> can be equal to: 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 he would like to add and compile by specifying DPDK_VER=<version_number>

            Please see DPDK release note to know which version are supported on which OS:

            http://dpdk.org/doc/guides/rel_notes/

     

    2. Second procedure - Download the entire compressed image from Docker Hub.

    This procedure is more strict and straightforward.

    # docker pull amirzei/mlnx_docker_dpdk:<os_version>

     

    Notes:

    • <os_version> can be equal to: ubuntu14.04 , ubuntu16.04 , rhel7.2 , rhel7.3
    • 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 hugespages:

    # 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 show allocation of 4G total hugepages for both 2Mb and 1G hugepages sizes. User can define different amount relative to his free amount of memory on the hypervisor.

     

    2. Define network for container.

    Recommended type of network is SRIOV.

    to view how to define SRIOV network please refer to this post:

    HowTo Configure Docker in SR-IOV or Passthrough Mode with Mellanox Ethernet Adapters

     

    Another way is to use 'host' network type. Both applicable.

     

    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>

     

    Notes:

    • This example use net type 'host', if choosing SRIOV there is a need to specify the SRIOV network name instead.
    • DPDK libraries located inside the container under /usr/src/dpdk-<version>/

           This directory contains compiled Mellanox PMD with defaults apps such as testpmd