[dpdk-dev] [PATCH v3] build: add dockerfile for building docker image

Ruifeng Wang (Arm Technology China) Ruifeng.Wang at arm.com
Thu Dec 5 15:13:46 CET 2019


> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Abdul Halim
> Sent: Tuesday, December 3, 2019 19:42
> To: dev at dpdk.org
> Cc: ray.kinsella at intel.com; yasufum.o at gmail.com; Abdul Halim
> <abdul.halim at intel.com>
> Subject: [dpdk-dev] [PATCH v3] build: add dockerfile for building docker
> image
> 
> Adding a Dockerfile with Ubuntu bionic base image to build dpdk as shared
> library. This docker image could be used as base image to build and run dpdk
> applications in containers.
> 
> Signed-off-by: Abdul Halim <abdul.halim at intel.com>
> 
> ---
> 
> v2:
>   * renamed Dockerfile name from Dockerfile.ubuntu to Dockerfile.bionic
>   * added call to ldconfig to update cache of libraries to include newly
>     installed DPDK libs
> 
> ---
> 
> v3:
>   * added example use-case of dpdk dockerfile in extras/README.md
> ---
>  extras/Dockerfile.bionic | 40
> +++++++++++++++++++++++++++++++++++++
>  extras/README.md         | 52
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 92 insertions(+)
>  create mode 100644 extras/Dockerfile.bionic  create mode 100644
> extras/README.md
> 
> diff --git a/extras/Dockerfile.bionic b/extras/Dockerfile.bionic new file mode
> 100644 index 0000000..f83b720
> --- /dev/null
> +++ b/extras/Dockerfile.bionic
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2019 Intel
> +Corporation FROM ubuntu:bionic
> +
> +# install requirements for getting and building DPDK # including
> +dependencies for DPDK features RUN apt-get update && apt-get install -y
> +\
> +    build-essential \
> +    pkg-config \
> +    python3 \
> +    python3-pip \
> +    ninja-build \
> +    libjansson-dev \
> +    libbsd-dev \
> +    libnuma-dev \
> +    libssl-dev \
> +    zlib1g-dev \
> +    libpcap-dev \
> +    libibverbs-dev \
> +        && pip3 install meson \
> +        && apt-get clean && rm -rf /var/lib/apt/lists/*
> +
> +ADD . /tmp/dpdk
> +
> +WORKDIR /tmp/dpdk
> +
> +RUN meson build \
> +    -Ddefault_library=shared \
> +    -Dmachine=default \
> +    -Dper_library_versions=false \
> +        && ninja -C build install \
> +        && ldconfig \
> +        && cd /; rm -rf /tmp/dpdk
> +
> +WORKDIR /
> +
> +# Installed DPDK Shared library location:
> +# lib dir : /usr/local/lib/
> +# include : /usr/local/include/
> +# pkgconfig file: /usr/local/lib/x86_64-linux-gnu/pkgconfig/libdpdk.pc
> diff --git a/extras/README.md b/extras/README.md new file mode 100644
> index 0000000..f38d7f1
> --- /dev/null
> +++ b/extras/README.md
> @@ -0,0 +1,52 @@
> +# Build DPDK Docker image
> +
> +To build a docker image run the following command from dpdk root
> directory.
> +
> +```
> +DOCKER_TAG="dpdk"
> +docker build -t ${DOCKER_TAG} -f extras/Dockerfile.bionic .
> +```
> +
> +# Example of how to use this dpdk library image
> +
> +The following steps shows how to use the dpdk shared library container
> +to build and run a dpdk application without having to build dpdk
> +library for each application.
> +
> +## Create a dpdk sample app docker file with 'dpdk' as the base image
> +
> +Create a docker file to build the dpdk helloworld application. Since,
> +we are creating a docker file for dpdk helloworld app we need to add
> +the dpdk source files, thus create the following docker file in dpdk root
> directory.
> +
> +```
> +cat << EOF > Dockerfile.dpdkSampleApp
> +FROM dpdk
> +
> +ADD . /opt/dpdk
> +
> +WORKDIR /opt/dpdk/examples/helloworld
> +RUN make && cp build/helloworld-shared /usr/local/bin/helloworld EOF
> +```
> +
> +## Build sample app docker image
> +
> +```
> +DOCKERAPP_TAG="dpdk-helloworld"
> +docker build -t ${DOCKERAPP_TAG} -f Dockerfile.dpdkSampleApp .
> +```

Hi Abdul,

I tried the steps on AArch64 platform, and hit error as below:

$ sudo docker build -t ${DOCKERAPP_TAG} -f Dockerfile.dpdkSampleApp .
Sending build context to Docker daemon   2.55GB
Step 1/4 : FROM dpdk
 ---> 955448007987
Step 2/4 : ADD . /opt/dpdk
 ---> d8b58019a7e2
Step 3/4 : WORKDIR /opt/dpdk/examples/helloworld
 ---> Running in 14fc89f7d3cd
Removing intermediate container 14fc89f7d3cd
 ---> 065a682c58fd
Step 4/4 : RUN make && cp build/helloworld-shared /usr/local/bin/helloworld
 ---> Running in 11e755a7180b
Makefile:44: *** "Please define RTE_SDK environment variable".  Stop.
The command '/bin/sh -c make && cp build/helloworld-shared /usr/local/bin/helloworld' returned a non-zero code: 2

Missing define of RTE_SDK and RTE_TARGET?

> +
> +This sample app now can be run like any other applicaiton in a docker
> container.
> +
> +```
> +$ docker run --rm -it  -v /dev/hugepages:/dev/hugepages dpdk-helloworld
> +```
> +
> +## Running the sample app
> +Once inside the container run helloword binary
> +
> +```
> +$ root at 11233ed2e69c # helloworld
> +```
> +
> --
> 1.8.3.1
> 
> --------------------------------------------------------------
> Intel Research and Development Ireland Limited Registered in Ireland
> Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
> Registered Number: 308263
> 
> 
> This e-mail and any attachments may contain confidential material for the
> sole use of the intended recipient(s). Any review or distribution by others is
> strictly prohibited. If you are not the intended recipient, please contact the
> sender and delete all copies.



More information about the dev mailing list