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 5, 2024
1 parent f7bf531 commit b0c75db
Showing 1 changed file with 11 additions and 5 deletions.
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 b0c75db

Please sign in to comment.