From 392a2ff5910295f98e3279fbbd0f818c520b3215 Mon Sep 17 00:00:00 2001 From: Frank Du Date: Wed, 8 Nov 2023 15:29:50 +0800 Subject: [PATCH] docker: add multiple docker containers support (#574) Use shared IPC option `--ipc=host` for the docker run command Signed-off-by: Frank Du --- docker/README.md | 33 +++++++++++++++++++++++++++------ docker/ubuntu.dockerfile | 5 ++++- lib/src/mt_sch.c | 4 ++-- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/docker/README.md b/docker/README.md index 7075b52ab..f29b2ac3e 100644 --- a/docker/README.md +++ b/docker/README.md @@ -14,19 +14,40 @@ Refer to below build command if you are in a proxy env. docker build -t mtl:latest -f ubuntu.dockerfile --build-arg HTTP_PROXY=http://proxy.xxx.com:xxx --build-arg HTTPS_PROXY=https://proxy.xxx.com:xxx ./ ``` -## 2. DPDK NIC PMD and env setup +## 2. DPDK NIC PMD and env setup on host -Please refer to [run guide](../doc/run.md) +Follow [run guide](../doc/run.md) to setup the hugepages, driver of NIC PF, vfio driver mode for VFs. -## 3. Run the docker image +## 3. Run and login into the docker container with root user + +The sample usage provided below is enabled with specific privileged settings such as VFIO access, a shared IPC namespace and root user inside the docker. + +### 3.1 Run the docker container + +The argument `/dev/vfio/` enables the Docker instance to access the VFIO device. + +The arguments `/dev/null, /tmp/kahawai_lcore.lock, and --ipc=host` and touch `/tmp/kahawai_lcore.lock` command are used for managing shared memory within IMTL, primarily for lcore management across multiple IMTL docker containers. + +```bash +touch /tmp/kahawai_lcore.lock +docker run --privileged -it -v /dev/vfio/:/dev/vfio/ -v /dev/null:/dev/null -v /tmp/kahawai_lcore.lock:/tmp/kahawai_lcore.lock --ipc=host mtl:latest +``` + +If you confirm that all IMTL processes will run within a single Docker container, you can disregard the settings related to shared memory. Simply execute the following command: ```bash -docker run --privileged -it -v /dev/vfio/vfio:/dev/vfio/vfio mtl:latest +docker run --privileged -it -v /dev/vfio/:/dev/vfio/ mtl:latest ``` -non-root run need additional permission settings for the vfio and hugepage. +### 3.2 Switch to the root user inside a Docker container + +On the docker bash shell: + +```bash +sudo -s +``` -## 3. Run RxTXApp inside docker +## 4. Run RxTXApp ```bash cd Media-Transport-Library/ diff --git a/docker/ubuntu.dockerfile b/docker/ubuntu.dockerfile index 699a61071..6f0e1369e 100644 --- a/docker/ubuntu.dockerfile +++ b/docker/ubuntu.dockerfile @@ -15,10 +15,13 @@ RUN apt-get update -y # Install dependencies RUN apt-get install -y git gcc meson python3 python3-pip pkg-config libnuma-dev libjson-c-dev libpcap-dev libgtest-dev libsdl2-dev libsdl2-ttf-dev libssl-dev -RUN pip install pyelftools==0.29 ninja==1.11.1 +RUN pip install pyelftools ninja RUN apt-get install -y sudo +# some misc tools +RUN apt-get install -y vim htop + RUN apt clean all # user: imtl diff --git a/lib/src/mt_sch.c b/lib/src/mt_sch.c index fb6068eef..e3cb23e18 100644 --- a/lib/src/mt_sch.c +++ b/lib/src/mt_sch.c @@ -528,8 +528,8 @@ static int sch_init_lcores(struct mt_sch_mgr* mgr) { memset(lcore_shm, 0, sizeof(*lcore_shm)); mgr->lcore_shm = lcore_shm; - info("%s, shared memory attached at %p nattch %d\n", __func__, mgr->lcore_shm, - (int)stat.shm_nattch); + info("%s, shared memory attached at %p nattch %d shm_id %d key 0x%x\n", __func__, + mgr->lcore_shm, (int)stat.shm_nattch, shm_id, (int)key); ret = sch_filelock_unlock(mgr); if (ret < 0) { err("%s, sch_filelock_unlock fail\n", __func__);