Skip to content

Commit

Permalink
testing_using_container: fix port forwarding
Browse files Browse the repository at this point in the history
--network=host tries to use privileged ports on the host
so it fails when run as user. Go back to port forwarding.

Also, let podman pick a number and print it.
  • Loading branch information
mvidner committed Jun 7, 2024
1 parent 88237f7 commit 0cddd65
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 1 addition & 2 deletions doc/testing_using_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ script. That scripts does several steps:
(using the [setup.sh](../setup.sh) script)
- It asks for the new root password to allow logging in (by default there is
no root password set in containers)
- It provides web UI on default host HTTP/HTTPS ports (connect to
`http://localhost`, port forwarding does not work for some reason)
- It provides web UI on a forwarded HTTPS port
- Starts a shell inside the container with root access for more testing or
debugging.
16 changes: 11 additions & 5 deletions testing_using_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Details:
# - container name: agama
# - port 9091 is exposed and forwarded to the container
# - SSL port is exposed (to a random port, printed out) so that web UI works
# - 'WITH_RUBY_DBUS=1 $0' will prefer ../ruby-dbus to any ruby-dbus.gem

set -x
Expand Down Expand Up @@ -34,12 +34,11 @@ if [ "${WITH_RUBY_DBUS-}" = 1 ]; then
MORE_VOLUMES=(-v ../ruby-dbus:/checkout-ruby-dbus)
fi

# use the host networking, port forwarding does not work for some reason :-/
podman run --name ${CNAME?} \
--privileged --detach \
-v .:/checkout \
${MORE_VOLUMES[@]} \
--network=host \
-p :443 \
${CIMAGE?}

# shortcut for the following
Expand All @@ -50,11 +49,18 @@ ${CEXEC?} "cd /checkout && ./setup.sh"
echo "Set the Agama (root) password:"
podman exec -it ${CNAME?} passwd

# Interactive shell in the container
podman exec --tty --interactive ${CNAME?} bash
PORT=$(podman port ${CNAME?} 443)
PORT=${PORT#*:}

set +x
echo "agama-web-server (container port 443) forwarded to https://localhost:$PORT/"
echo "To attach again to the Agama container run:"
echo " podman exec --tty --interactive ${CNAME?} bash"
echo "To stop and remove the Agama container run:"
echo " podman stop ${CNAME?}"
echo " podman rm ${CNAME?}"
set -x

# Interactive shell in the container
podman exec --tty --interactive ${CNAME?} bash

0 comments on commit 0cddd65

Please sign in to comment.