Add explanation about how container runtimes like podman or docker can be used to build and run DPDK application.
Signed-off-by: Andrea Panattoni <[email protected]> --- .mailmap | 1 + doc/guides/linux_gsg/build_dpdk.rst | 48 ++++++++++++++++++++++ doc/guides/linux_gsg/build_sample_apps.rst | 32 +++++++++++++++ 3 files changed, 81 insertions(+) diff --git a/.mailmap b/.mailmap index 89ba6ffccc..48133a4b45 100644 --- a/.mailmap +++ b/.mailmap @@ -109,6 +109,7 @@ Andre Muezerie <[email protected]> <[email protected]> Andre Richter <[email protected]> Andrea Arcangeli <[email protected]> Andrea Grandi <[email protected]> +Andrea Panattoni <[email protected]> Andrew Bailey <[email protected]> Andrew Boyer <[email protected]> <[email protected]> Andrew Harvey <[email protected]> diff --git a/doc/guides/linux_gsg/build_dpdk.rst b/doc/guides/linux_gsg/build_dpdk.rst index ed30e4a5f1..cfd10c0310 100644 --- a/doc/guides/linux_gsg/build_dpdk.rst +++ b/doc/guides/linux_gsg/build_dpdk.rst @@ -337,3 +337,51 @@ build system is shown below: dpdk = dependency('libdpdk') sources = files('main.c') executable('dpdk-app', sources, dependencies: dpdk) + + +.. _building_dpdk_in_container: + +Building Applications in a Container +------------------------------------ + +DPDK can be built inside a container to provide a reproducible build environment. +The following example uses Podman with a Fedora-based Containerfile. + +.. note:: + + These instructions also work with Docker by replacing ``podman`` with ``docker``. + +Create a ``Containerfile`` in the top-level DPDK source directory: + +.. code-block:: none + + FROM fedora:latest + + RUN dnf -y upgrade && dnf -y install \ + libbsd-devel \ + numactl-devel \ + meson \ + ninja-build \ + python3-pyelftools \ + && dnf group install -y development-tools \ + && dnf clean all + + COPY ./ /dpdk + WORKDIR /dpdk + + RUN meson setup build -Dexamples=helloworld && ninja -C build install + +Build the container image from the DPDK source directory: + +.. code-block:: console + + podman build -t dpdk-builder -f Containerfile . + +Once the build completes, verify that the helloworld example runs: + +.. code-block:: console + + podman run --rm dpdk-builder /dpdk/build/examples/dpdk-helloworld + +See :ref:`running_sample_app_in_container` for how to run DPDK applications +from this container image. diff --git a/doc/guides/linux_gsg/build_sample_apps.rst b/doc/guides/linux_gsg/build_sample_apps.rst index 5195af67ad..7154f64723 100644 --- a/doc/guides/linux_gsg/build_sample_apps.rst +++ b/doc/guides/linux_gsg/build_sample_apps.rst @@ -125,3 +125,35 @@ Additional sample applications are included in the DPDK examples directory. These sample applications may be built and run in a manner similar to that described in earlier sections in this manual. In addition, see the *DPDK Sample Applications User Guide* for a description of the application, specific instructions on compilation and execution and some explanation of the code. + + +.. _running_sample_app_in_container: + +Running Sample Application in a Container +----------------------------------------- + +A DPDK application can be run inside a container using the image built +in :ref:`building_dpdk_in_container`. + +.. warning:: + + Hugepages must be configured on the host before running a DPDK application + in a container. + Refer to :ref:`linux_gsg_hugepages` for setup instructions. + +The following example runs testpmd in interactive mode with no physical NICs: + +.. code-block:: console + + podman run -it --privileged \ + -v /dev/hugepages:/dev/hugepages \ + dpdk-builder \ + ./build/app/dpdk-testpmd --no-pci -- -i + +.. note:: + + The ``--privileged`` flag grants access to hugepages and hardware resources. + For production deployments, consider using more fine-grained capabilities + and device access instead. + + These instructions also work with Docker by replacing ``podman`` with ``docker``. -- 2.54.0

