From 8f927646454893c9e48639a44b4528866a78d4a0 Mon Sep 17 00:00:00 2001 From: devosc Date: Sat, 22 Feb 2020 07:52:58 -0600 Subject: [PATCH] add container to network --- bin/docker-php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/docker-php b/bin/docker-php index 43a1b6b..746dd9d 100755 --- a/bin/docker-php +++ b/bin/docker-php @@ -10,6 +10,7 @@ directory="$(pwd)" extra_hosts="${EXTRA_HOSTS}" hosts="" name="php-docker-project-cli" +network="" no_cache="" ssh_dir="" tag="latest" @@ -35,6 +36,7 @@ Commands: Options: --add-host list Add custom host-to-IP mapping, e.g example.com:192.168.10.10. --build Build image from Dockerfile. + --network NAME Name of network to connect the container to, e.g. traefik_webgateway. --no-cache Do not use cache when building the image. --project-directory PATH Alternative working directory, default is current directory. --ssh-keys Mount user ssh directory." @@ -54,6 +56,9 @@ for ((i=0; i < "$#"; ++i)); do unset "args[i]" "args[i+1]" i=$(expr ${i} + 1) ;; + --network ) network="--network ${args[i+1]}" + unset "args[i]" "args[i+1]" + ;; --no-cache ) no_cache="--no-cache" unset "args[i]" ;; @@ -115,4 +120,4 @@ if [[ -z "${hosts}" ]] && [[ -n "${extra_hosts}" ]]; then done fi -docker run -it --rm --name "${name}" ${hosts} -v "${volume}" ${ssh_dir} ${composer_dir} -w "${work_dir}" -u "${user}" "${image}" ${cmd} "${args[@]}" +docker run -it --rm --name "${name}" ${hosts} -v "${volume}" ${network} ${ssh_dir} ${composer_dir} -w "${work_dir}" -u "${user}" "${image}" ${cmd} "${args[@]}"