Merge pull request #187 into master

050d95b client: src: lib_docker: `run`: only allocate TTY when needed (Aaron Fiore)
This commit was merged in pull request #187.
This commit is contained in:
2025-03-21 10:48:37 -07:00

View File

@@ -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"