From 3d7bf7da2d9371dde3053efc5b376f9664ece3ea Mon Sep 17 00:00:00 2001 From: Bruce Ashfield Date: Thu, 8 Jan 2026 19:34:19 +0000 Subject: vcontainer: fix ps -q to suppress port forward display When using `ps -q` or `ps --quiet`, only container IDs should be output. The port forward registry display was being included, which broke cleanup code that expected just container IDs. Signed-off-by: Bruce Ashfield --- recipes-containers/vcontainer/files/vcontainer-common.sh | 10 +++++++++- tests/test_vdkr.py | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/recipes-containers/vcontainer/files/vcontainer-common.sh b/recipes-containers/vcontainer/files/vcontainer-common.sh index 9003e0c7..b0623164 100755 --- a/recipes-containers/vcontainer/files/vcontainer-common.sh +++ b/recipes-containers/vcontainer/files/vcontainer-common.sh @@ -1333,7 +1333,15 @@ case "$COMMAND" in PS_EXIT=$? # Show host port forwards if daemon is running and we have any - if daemon_is_running; then + # Skip if -q/--quiet flag is present (only container IDs requested) + PS_QUIET=false + for arg in "${COMMAND_ARGS[@]}"; do + case "$arg" in + -q|--quiet) PS_QUIET=true; break ;; + esac + done + + if [ "$PS_QUIET" = "false" ] && daemon_is_running; then pf_file=$(get_port_forward_file) if [ -f "$pf_file" ] && [ -s "$pf_file" ]; then echo "" diff --git a/tests/test_vdkr.py b/tests/test_vdkr.py index c343e05f..33744107 100644 --- a/tests/test_vdkr.py +++ b/tests/test_vdkr.py @@ -101,16 +101,16 @@ class TestPortForwarding: # Stop any running memres first vdkr.memres_stop() - # Start memres with port forwarding - result = vdkr.memres_start(timeout=180, port_forwards=["8080:80"]) + # Start memres (no static port forwards needed - use dynamic via -p on run) + result = vdkr.memres_start(timeout=180) assert result.returncode == 0, f"memres start failed: {result.stderr}" try: # Pull nginx:alpine if not present vdkr.run("pull", "nginx:alpine", timeout=300) - # Run nginx (--network=host is the default) - result = vdkr.run("run", "-d", "--rm", "nginx:alpine", timeout=60) + # Run nginx with port forward - Docker sets up iptables for bridge networking + result = vdkr.run("run", "-d", "--rm", "-p", "8080:80", "nginx:alpine", timeout=60) assert result.returncode == 0, f"nginx run failed: {result.stderr}" # Give nginx time to start -- cgit v1.2.3-54-g00ecf