Skip to content

Commit ffd7580

Browse files
committed
tutorials/test: add test container
Add test container to easily spot if users are struggling starting privileged containers managing Linux network namespaces. Hopefully this will never fail...
1 parent 6281598 commit ffd7580

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed

.github/workflows/publish_docker_images.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ permissions:
1111
env:
1212
PLATFORMS: linux/amd64,linux/arm64
1313
BUILD_DIRS: |
14+
tutorials/test/
1415
tutorials/net/mtu/
1516
1617
jobs:

tutorials/test/BANNER

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=================================================
2+
🐧 bitpuff.io tutorial setup test 🐧
3+
=================================================
4+
This container tests that your docker setup is
5+
correct, and that privileged containers can
6+
create Linux network namespaces (NSs).
7+
-------------------------------------------------

tutorials/test/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Test setup container
2+
3+
This container image tests that your docker setup is correct, and that privileged
4+
containers can create [Linux Network namespaces](https://man7.org/linux/man-pages/man7/network_namespaces.7.html).
5+
6+
## How to use it
7+
8+
```
9+
docker run --privileged ghcr.io/bitpuff-io/tutorials.test
10+
```

tutorials/test/docker/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM debian:latest
2+
3+
LABEL maintainer="Marc Sune <[email protected]>"
4+
LABEL version="latest"
5+
LABEL description="bitpuff.io MTU setup test"
6+
LABEL org.opencontainers.image.authors="Marc Sune <[email protected]>"
7+
LABEL org.opencontainers.image.url="https://github.com/bitpuff-io/code/"
8+
LABEL org.opencontainers.image.documentation="https://bitpuff.io/tutorials/setup/"
9+
LABEL org.opencontainers.image.source="https://github.com/bitpuff-io/code/"
10+
LABEL org.opencontainers.image.licenses="BSD"
11+
12+
RUN apt update && apt install -y --no-install-recommends \
13+
iproute2 \
14+
&& rm -rf /var/lib/apt/lists/*
15+
16+
RUN mkdir /bp
17+
COPY . /bp
18+
WORKDIR /root
19+
CMD ["/bp/entrypoint.sh"]

tutorials/test/docker/tag

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tutorials.test

tutorials/test/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
cat /bp/BANNER
6+
7+
echo "[INFO] Creating namespace 'bp_test_ns'..."
8+
ip netns add bp_test_ns
9+
10+
echo "[INFO] Executing command inside the NS..."
11+
ip netns exec bp_test_ns echo "Hello world!"
12+
13+
echo "[INFO] All is good!"

0 commit comments

Comments
 (0)