diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands index 9233e8a0e..9c1819ee5 100755 --- a/plugins/00_dokku-standard/commands +++ b/plugins/00_dokku-standard/commands @@ -49,7 +49,9 @@ case "$1" in shift 2 DOCKER_ARGS=$(: | pluginhook docker-args $APP run) - docker run -i -t $DOCKER_ARGS $IMAGE /exec "$@" + # if we have a prompt, then we have a tty according to the LDP (http://www.tldp.org/LDP/abs/html/intandnonint.html) + [[ ! -z "$PS1" ]] && DOKKU_RUN_OPTS="-i -t" + docker run $DOKKU_RUN_OPTS $DOCKER_ARGS $IMAGE /exec "$@" ;; url | urls) diff --git a/tests/unit/00_dokku-standard.bats b/tests/unit/00_dokku-standard.bats index 930dad279..c8abfbfba 100644 --- a/tests/unit/00_dokku-standard.bats +++ b/tests/unit/00_dokku-standard.bats @@ -11,6 +11,22 @@ teardown() { destroy_app } +@test "run (with tty)" { + deploy_app + run /bin/bash -c "dokku run $TEST_APP ls /app/package.json" + echo "output: "$output + echo "status: "$status + assert_success +} + +@test "run (without tty)" { + deploy_app + run /bin/bash -c ": |dokku run $TEST_APP ls /app/package.json" + echo "output: "$output + echo "status: "$status + assert_success +} + @test "urls (non-ssl)" { run bash -c "dokku urls $TEST_APP | grep dokku.me" echo "output: "$output