Skip to content

Commit

Permalink
docker: add multiple docker containers support (#574)
Browse files Browse the repository at this point in the history
Use shared IPC option `--ipc=host` for the docker run command

Signed-off-by: Frank Du <[email protected]>
  • Loading branch information
frankdjx authored Nov 8, 2023
1 parent 8269cd7 commit 392a2ff
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
33 changes: 27 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
5 changes: 4 additions & 1 deletion docker/ubuntu.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/src/mt_sch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand Down

0 comments on commit 392a2ff

Please sign in to comment.