summaryrefslogtreecommitdiffstats
path: root/recipes-containers/vcontainer
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-01-08 17:07:48 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-02-09 03:32:52 +0000
commit6b18259bd97f6d350f18eccbdd0b81fbc2bd982e (patch)
tree6e114be575ad7409ac8681b420004c13335d297e /recipes-containers/vcontainer
parent3c01c9aaa14b5385cbdb176a4c721ecc8fa45088 (diff)
downloadmeta-virtualization-6b18259bd97f6d350f18eccbdd0b81fbc2bd982e.tar.gz
vdkr: enable Docker bridge networking
Enable Docker's default bridge network (docker0, 172.17.0.0/16) inside the QEMU VM to allow multiple containers to listen on the same internal port with different host port mappings. Changes: - Add iptables package to vdkr-rootfs-image for Docker NAT rules - Change dockerd options in vdkr-init.sh: - Set --iptables=true (was false) - Remove --bridge=none to enable default docker0 bridge This enables the workflow: vdkr run -d -p 8080:80 --name nginx1 nginx:alpine vdkr run -d -p 8081:80 --name nginx2 nginx:alpine # Both work - each container gets its own 172.17.0.x IP Previously with --network=host (the old default), both containers would try to bind port 80 on the VM's single IP, causing conflicts. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers/vcontainer')
-rwxr-xr-xrecipes-containers/vcontainer/files/vdkr-init.sh5
-rw-r--r--recipes-containers/vcontainer/vdkr-rootfs-image.bb5
2 files changed, 6 insertions, 4 deletions
diff --git a/recipes-containers/vcontainer/files/vdkr-init.sh b/recipes-containers/vcontainer/files/vdkr-init.sh
index 7cfe12af..efe56049 100755
--- a/recipes-containers/vcontainer/files/vdkr-init.sh
+++ b/recipes-containers/vcontainer/files/vdkr-init.sh
@@ -92,9 +92,10 @@ start_dockerd() {
92 log "Starting Docker daemon..." 92 log "Starting Docker daemon..."
93 DOCKER_OPTS="--data-root=/var/lib/docker" 93 DOCKER_OPTS="--data-root=/var/lib/docker"
94 DOCKER_OPTS="$DOCKER_OPTS --storage-driver=overlay2" 94 DOCKER_OPTS="$DOCKER_OPTS --storage-driver=overlay2"
95 DOCKER_OPTS="$DOCKER_OPTS --iptables=false" 95 # Enable iptables for Docker bridge NAT and port forwarding
96 DOCKER_OPTS="$DOCKER_OPTS --iptables=true"
96 DOCKER_OPTS="$DOCKER_OPTS --userland-proxy=false" 97 DOCKER_OPTS="$DOCKER_OPTS --userland-proxy=false"
97 DOCKER_OPTS="$DOCKER_OPTS --bridge=none" 98 # Use default docker0 bridge (172.17.0.0/16) for container networking
98 DOCKER_OPTS="$DOCKER_OPTS --host=unix:///var/run/docker.sock" 99 DOCKER_OPTS="$DOCKER_OPTS --host=unix:///var/run/docker.sock"
99 DOCKER_OPTS="$DOCKER_OPTS --exec-opt native.cgroupdriver=cgroupfs" 100 DOCKER_OPTS="$DOCKER_OPTS --exec-opt native.cgroupdriver=cgroupfs"
100 DOCKER_OPTS="$DOCKER_OPTS --log-level=info" 101 DOCKER_OPTS="$DOCKER_OPTS --log-level=info"
diff --git a/recipes-containers/vcontainer/vdkr-rootfs-image.bb b/recipes-containers/vcontainer/vdkr-rootfs-image.bb
index a9bbb9fa..079f4c17 100644
--- a/recipes-containers/vcontainer/vdkr-rootfs-image.bb
+++ b/recipes-containers/vcontainer/vdkr-rootfs-image.bb
@@ -9,8 +9,8 @@
9# to provide a proper rootfs for running Docker in QEMU. 9# to provide a proper rootfs for running Docker in QEMU.
10# 10#
11# Build with: 11# Build with:
12# bitbake mc:vdkr-aarch64:vdkr-rootfs-image 12# bitbake mc:vruntime-aarch64:vdkr-rootfs-image
13# bitbake mc:vdkr-x86-64:vdkr-rootfs-image 13# bitbake mc:vruntime-x86-64:vdkr-rootfs-image
14 14
15SUMMARY = "Minimal Docker rootfs for vdkr" 15SUMMARY = "Minimal Docker rootfs for vdkr"
16DESCRIPTION = "A minimal image containing Docker tools for use with vdkr. \ 16DESCRIPTION = "A minimal image containing Docker tools for use with vdkr. \
@@ -40,6 +40,7 @@ IMAGE_INSTALL = " \
40 skopeo \ 40 skopeo \
41 busybox \ 41 busybox \
42 iproute2 \ 42 iproute2 \
43 iptables \
43 util-linux \ 44 util-linux \
44" 45"
45 46