From 81917960505cd20d5c4ab48e78058100c121bc6e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Fri, 17 Nov 2017 14:06:47 -0800 Subject: [PATCH] Avoid port conflicts (#93) --- rootfs/templates/wrapper | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rootfs/templates/wrapper b/rootfs/templates/wrapper index 93679c307..f797bebea 100755 --- a/rootfs/templates/wrapper +++ b/rootfs/templates/wrapper @@ -9,7 +9,7 @@ fi set -o pipefail # Geodesic Settings -export GEODESIC_PORT=${GEODESIC_PORT:-8001} +export GEODESIC_PORT=${GEODESIC_PORT:-$((30000 + $$%30000))} STATE_DIR=${STATE_DIR:-${HOME}/.geodesic} OS=$(uname -s) @@ -116,6 +116,7 @@ function use() { docker exec -it "${DOCKER_NAME}" $* else echo "# Starting new ${DOCKER_NAME} session from ${DOCKER_IMAGE}" + echo "# Exposing port ${GEODESIC_PORT}" docker run "${DOCKER_ARGS[@]}" ${DOCKER_IMAGE} -l $* fi } @@ -217,6 +218,10 @@ else export DOCKER_IMAGE=${DOCKER_IMAGE}:${DOCKER_TAG} fi +if [ -n "${PORT}" ]; then + export GEODESIC_PORT=${PORT} +fi + export DOCKER_DNS=${DNS:-8.8.8.8} if [ "${GEODESIC_SHELL}" == "true" ]; then