From 24c6452c31ed4d44a9cf920bc1f6a14301513240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Wed, 29 Jun 2022 23:22:17 +0200 Subject: [PATCH] Add basic docker utility for running command from current directory --- symlinks/bin/dockercwd | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 symlinks/bin/dockercwd diff --git a/symlinks/bin/dockercwd b/symlinks/bin/dockercwd new file mode 100755 index 0000000..3529e00 --- /dev/null +++ b/symlinks/bin/dockercwd @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Runs command in cwd from docker (mounts cwd to /app in docker) +POSITIONAL=() +NETWORK=docker_default +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -n|--network) + NETWORK=$2 + shift # past argument + shift # past value + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done + +echo "docker run -it --rm --network $NETWORK --mount type=bind,source="$(pwd)",target=/app ${POSITIONAL[@]}" +docker run -it --rm --network $NETWORK --mount type=bind,source="$(pwd)",target=/app ${POSITIONAL[@]}