Create and Configure a Container

Enabling the Napatech SmartNICs with Link-Capture™ Software in Containers

Platform
Napatech SmartNIC
Content Type
Application Note
Capture Software Version
Link™ Capture Software 12.11

This procedure creates a docker container and configures it to share the IPC namespace of the host, mounts three host directories as volumes into the container, and provides access to the device file.

Before you begin

Make sure you have:

About this task

The following parameters of the docker run command enable containers to access the IPC namespace, volumes and devices on the host.
  • --ipc: Specifies the IPC namespace to use.
  • --device: Adds a host device to the container.
  • -v, --volume: Binds a volume for mounting.
These parameters facilitates the execution of Napatech Link-Capture™ Software tools and applications in containers, enabling the following tasks.
  • libntapi in the container communicates with ntservice on the host.
  • libntapi in the container maps memory (mmap) for host buffers.

Procedure

  1. Start the driver.
    /opt/napatech3/bin/ntstart.sh
    An output example:
    Loading nt3gd driver                                        [Done]
    Creating driver device file                                 [Done]
    Loading nt3gd_netdev driver                                 [Done]
    Creating driver device file                                 [Done]
    Starting NTService (this may take a while)                  [Done]
  2. Create a new container.
    For example:
    docker pull dokken/centos-stream-8
    docker run -it --ipc=host -v /var/run/napatech:/var/run/napatech \
    -v /dev/nt3gd:/dev/nt3gd -v /opt/napatech3/lib:/opt/napatech3/lib \
    --device=/dev/nt3gd dokken/centos-stream-8 /bin/bash
    where:
    • --ipc=host: Shares the IPC namespace of the host system with the container. It means that the container and the host can use the same IPC mechanisms.
    • -v /var/run/napatech:/var/run/napatech: Creates a volume (-v) by mounting the /var/run/napatech directory on the host system into the /var/run/napatech directory in the container. This allows data to be shared between the host and the container.
    • -v /dev/nt3gd:/dev/nt3gd: Creates another volume by mounting the /dev/nt3gd device file of the host system in the container to provide access to the /dev/nt3gd device on the host.
    • -v /opt/napatech3/lib:/opt/napatech3/lib: Creates a volume by mounting the /opt/napatech3/lib directory on the host system into the /opt/napatech3/lib directory in the container to share the library files.
      Note: The container must use the Napatech Link-Capture™ Software libraries that match the driver running on the host. This can be resolved by binding the /opt/napatech3/lib directory on the host to the /opt/napatech3/lib directory in the container, as demonstrated in this step.
    • --device=/dev/nt3gd: Grants access to the /dev/nt3gd device from the host system to the container, making it available in the container for direct interaction with the device.
    • dokken/centos-stream-8: Specifies the container image used to create the container. In this case, it's the official CentOS-Stream 8 image.

    • /bin/bash: This is the command that will be executed within the container. It launches a bash shell, providing an interactive command-line environment within the container.

  3. Copy tools from the host to the container.
    In the container, create the /opt/napatech3/bin directory as follows:
    mkdir -p /opt/napatech3/bin

    On the host, copy the tools to be used in the container. For example:

    docker cp /etc/ld.so.conf.d/napatech3.conf bd2b81cd396c:/etc/ld.so.conf.d/
    docker cp /opt/napatech3/bin/ntlog bd2b81cd396c:/opt/napatech3/bin
    docker cp /opt/napatech3/bin/monitoring bd2b81cd396c:/opt/napatech3/bin
    docker cp /opt/napatech3/bin/throughput bd2b81cd396c:/opt/napatech3/bin
    ldconfig
    The container is ready to be tested with tools and applications.