From 050d95b60bdd4b35ebb95bf3e754741ab6b97d93 Mon Sep 17 00:00:00 2001 From: Aaron Fiore Date: Thu, 20 Mar 2025 18:39:38 -0700 Subject: [PATCH] client: src: lib_docker: `run`: only allocate TTY when needed Fixes running with client (host) cron. --- client/src/docker/lib/internal/lib_docker.bash | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/docker/lib/internal/lib_docker.bash b/client/src/docker/lib/internal/lib_docker.bash index 802f6d5..c793762 100644 --- a/client/src/docker/lib/internal/lib_docker.bash +++ b/client/src/docker/lib/internal/lib_docker.bash @@ -394,9 +394,14 @@ function lib_docker::__run() lib_utils::print_debug "Creating network" docker network create "$global_network" &>/dev/null - # NOTE: runs bash as interactive so .bashrc doesn't `return` (sources/aliases are needed) lib_utils::print_debug "Spawning container with command '$*'" - lib_docker::__docker_compose run -it --rm --entrypoint='/bin/bash -i -c' docker-finance "$@" + + # Terminal requirements (e.g., for cron, don't allocate TTY) + local _tty + test -t 1 && _tty="t" + + # NOTE: runs bash as interactive so .bashrc doesn't `return` (sources/aliases are needed) + lib_docker::__docker_compose run -i"${_tty}" --rm --entrypoint='/bin/bash -i -c' docker-finance "$@" local -r _return=$? lib_utils::print_debug "Removing network"