Merge pull request #4701 from dokku/4699-run-list

Revamp dokku run command
This commit is contained in:
Jose Diaz-Gonzalez
2021-07-27 14:42:56 -04:00
committed by GitHub
26 changed files with 257 additions and 129 deletions

View File

@@ -3,7 +3,10 @@
## Changes
- The network plugin can now set an `initial-network` for all containers on creation. This is a replacement for specifying the `--network` flag via the `docker-options` plugin. Please see the [network documentation](/docs/networking/network.md#attaching-an-app-to-a-network) for more information.
- The `dokku run` command now always removes the ephemeral container on exit. Users that need a persistent container should instead specify a `console` process type in their `Procfile` specifying an available shell (usually either `bash` or `sh`) and scale that container appropriately.
## Deprecations
- In previous versions of Dokku, the only way to specify a custom `Dockerfile` was to use the `docker-options` plugin to set the `--file` flag for a docker build. As of 0.25.0, the `builder-dockerfile:set` command should be used instead, as outlined in the [docs here](/docs/deployment/builders/dockerfiles.md#changingthe-dockerfile-location). Usage of the old method should be migrated to the new method.
- The `--rm` and ``--rm-container` flags may be specified but no longer have any effect on `dokku run`.
- The `--detach` flag is deprecated in favor of the `run:detached` command.

View File

@@ -91,11 +91,11 @@ The following config variables have special meanings and can be set in a variety
| `DOKKU_EVENTS_LOGFILE` | `$DOKKU_LOGS_DIR/events.log` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | Where the events log file is written to. |
| `DOKKU_APP_NAME` | none | `--app APP` flag | Name of application to work on. Respected by core plugins. |
| `DOKKU_APPS_FORCE_DELETE` | none | `--force` flag | Whether to force delete an application. Also used by other plugins for destructive actions. |
| `DOKKU_CHECKS_URL` | `https://dokku.com/docs/deployment/zero-downtime-deploys/` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | Url displayed during deployment when no CHECKS file exists. |
| `DOKKU_DETACH_CONTAINER` | none | `--detach` flag | Whether to detach a container started via `dokku run`. |
| `DOKKU_CHECKS_URL` | `https://dokku.com/docs/deployment/zero-downtime-deploys/` | `/etc/environment` <br /> `~dokku/.dokkurc` <br /> `~dokku/.dokkurc/*` | Url displayed during deployment when no CHECKS file exists. |
| `DOKKU_DETACH_CONTAINER` | none | `--detach` flag | Deprecated: Whether to detach a container started via `dokku run`. |
| `DOKKU_QUIET_OUTPUT` | none | `--quiet` flag | Silences certain header output for `dokku` commands. |
| `DOKKU_RM_CONTAINER` | none | `dokku config:set` <br /> `--rm-container` flag <br /> `--rm` flag | Whether to keep `dokku run` containers around or not. |
| `DOKKU_TRACE` | none | `dokku trace:on` <br /> `dokku trace:off` <br /> `--trace` flag | Turn on very verbose debugging. |
| `DOKKU_RM_CONTAINER` | none | `dokku config:set` <br /> | Deprecated: Whether to keep `dokku run` containers around or not. |
| `DOKKU_TRACE` | none | `dokku trace:on` <br /> `dokku trace:off` <br /> `--trace` flag | Turn on very verbose debugging. |
| `DOKKU_APP_PROXY_TYPE` | `nginx` | `dokku proxy:set` | |
| `DOKKU_APP_RESTORE` | `1` | `dokku config:set` <br /> `dokku ps:stop` | |
| `DOKKU_APP_SHELL` | `/bin/bash` | `dokku config:set` | Allows users to change the default shell used by Dokku for `dokku enter` and execution of deployment tasks. |

View File

@@ -17,7 +17,6 @@ in order to avoid SSH interpretting Dokku arguments for itself.
```
--quiet suppress output headers
--trace enable DOKKU_TRACE for current execution only
--rm|--rm-container remove docker container after successful dokku run <app> <command>
--force force flag. currently used in apps:destroy and other ":destroy" commands
```

View File

@@ -1,23 +1,31 @@
# One-off Tasks
```
run [ --env KEY=VALUE | -e KEY=VALUE ] <app> <cmd> # Run a command in a new container using the current application image
run [-e|--env KEY=VALUE] [--no-tty] <app> <cmd> # Run a command in a new container using the current app image
run:detached [-e|-env KEY=VALUE] [--no-tty] <app> <cmd> # Run a command in a new detached container using the current app image
run:list [<app>] # List all run containers for an app
```
Sometimes it is necessary to run a one-off command under an application. Dokku makes it easy to run a fresh container via the `run` command.
Sometimes it is necessary to run a one-off command under an app. Dokku makes it easy to run a fresh container via the `run` command.
## Usage
The `run` command can be used to run a one-off process for a specific command. This will start a new container and run the desired command within that container. Note that this container image will be stay around even after command completes. The container image will be the same container image as was used to start the currently deployed application.
### Running a one-off command
The `run` command can be used to run a one-off process for a specific command. This will start a new container and run the desired command within that container. The container image will be the same container image as was used to start the currently deployed app.
> New as of 0.25.0, this container will be removed after the process exits.
```shell
# runs `ls -lah` in the `/app` directory of the application `node-js-app`
# runs `ls -lah` in the `/app` directory of the app `node-js-app`
dokku run node-js-app ls -lah
# optionally, run can be passed custom environment variables
dokku run --env "NODE_ENV=development" --env "PATH=/custom/path" node-js-app npm run mytask
```
#### Running Procfile commands
The `run` command can also be used to run a command defined in the app `Procfile`:
```
@@ -25,26 +33,11 @@ console: bundle exec racksh
```
```shell
# runs `bundle exec racksh` in the `/app` directory of the application `my-app`
# runs `bundle exec racksh` in the `/app` directory of the app `my-app`
dokku run my-app console
```
If the container running the command should be removed after exit, the `--rm-container` or `--rm` global flags can be specified to remove the containers automatically:
```shell
dokku --rm-container run node-js-app ls -lah
dokku --rm run node-js-app ls -lah
```
Alternatively, a global property can be set to always remove `run` containers.
```shell
# don't keep `run` containers around
dokku config:set --global DOKKU_RM_CONTAINER=1
# revert the above setting and keep containers around
dokku config:unset --global DOKKU_RM_CONTAINER
```
#### Specifying container labels
Containers may have specific labels attached. In order to avoid issues with dokku internals, do not use any labels beginning with either `com.dokku` or `org.label-schema`.
@@ -52,11 +45,41 @@ Containers may have specific labels attached. In order to avoid issues with dokk
dokku --label=com.example.test-label=value run node-js-app ls -lah
```
Finally, a container can be run in "detached" mode via the `--detach` Dokku flag. Running a process in detached mode will immediately return a `CONTAINER_ID`. It is up to the user to then further manage this container in whatever manner they see fit, as Dokku will *not* automatically terminate the container.
#### Disabling TTY
> New as of 0.25.0
One-off containers default to interactive mode where possible. To disable this behavior, specify the `--no-tty` flag:
```shell
dokku --detach run node-js-app ls -lah
dokku run --no-tty node-js-app ls -lah
```
### Running a detached container
> New as of 0.25.0
Finally, a container can be run in "detached" mode via the `run:detached` Dokku command. Running a process in detached mode will immediately return a `CONTAINER_ID`. It is up to the user to then further manage this container in whatever manner they see fit, as Dokku will *not* automatically terminate the container.
```shell
dokku run:detached node-js-app ls -lah
# returns the ID of the new container
```
> Note that the `--rm-container` or `--rm` flags cannot be used when running containers in detached mode, and attempting to do so will result in the `--detach` flag being ignored.
### Listing one-off containers
> New as of 0.25.0
One-off containers for a given app can be listed via the `run:list` command:
```shell
dokku run:list node-js-app
```
```
=====> node-js-app run containers
NAMES COMMAND CREATED
node-js-app.run.28689 "/exec sleep 15" 2 seconds ago
```
> The `COMMAND` displayed will be what Docker executes and may not exactly match the command specified by a `dokku run` command.

4
dokku
View File

@@ -141,7 +141,7 @@ execute_dokku_cmd() {
nginx | nginx:*)
local PLUGIN_NAME=${PLUGIN_NAME/nginx/nginx-vhosts}
;;
deploy | run | cleanup | url | urls | report)
deploy | cleanup | url | urls | report)
local PLUGIN_NAME="00_dokku-standard"
;;
esac
@@ -207,7 +207,7 @@ case "$1" in
done
# New lines are blank echos for readability
dokku_log_quiet "Usage: dokku [--quiet|--trace|--rm-container|--rm|--force] COMMAND <app> [command-specific-options]"
dokku_log_quiet "Usage: dokku [--quiet|--trace|--force] COMMAND <app> [command-specific-options]"
dokku_log_quiet ""
dokku_log_quiet "Primary help options, type \"dokku COMMAND:help\" for more details, or dokku help --all to see all commands."
dokku_log_quiet ""

View File

@@ -1,11 +1,11 @@
#!/usr/bin/env bash
[[ " help help:help cleanup:help run:help url:help urls:help version:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
[[ " help help:help cleanup:help url:help urls:help version:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/00_dokku-standard/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | cleanup:help | run:help | url:help | urls:help | version:help)
help | cleanup:help | url:help | urls:help | version:help)
cmd-standard-help "$@"
;;

View File

@@ -18,7 +18,6 @@ fn-help-content() {
declare desc="return help content"
cat <<help_content
cleanup [<app>], Cleans up exited/dead Docker containers and removes dangling images
run [--env KEY=VALUE] <app> <cmd>, Run a command in a new container using the current application image
url <app>, Show the first URL for an application (compatibility)
urls <app>, Show all URLs for an application
version , Print dokku's version

View File

@@ -0,0 +1 @@
hook

View File

@@ -4,6 +4,10 @@ set -eo pipefail
has_tty() {
declare desc="return 0 if we have a tty"
if [[ "$DOKKU_DISABLE_TTY" == "true" ]]; then
return 1
fi
if [[ "$(LC_ALL=C /usr/bin/tty || true)" == "not a tty" ]]; then
return 1
else
@@ -433,13 +437,14 @@ parse_args() {
export DOKKU_QUIET_OUTPUT=1
;;
--detach)
dokku_log_warn_quiet "Deprecated: use run:detached instead of using the --detach flag"
export DOKKU_DETACH_CONTAINER=1
;;
--trace)
export DOKKU_TRACE=1
;;
--rm-container | --rm)
export DOKKU_RM_CONTAINER=1
dokku_log_warn_quiet "Deprecated: all run containers are now removed on exit by default"
;;
--force)
export DOKKU_APPS_FORCE_DELETE=1

View File

@@ -33,7 +33,7 @@ func (t templateCommand) CronCommand() string {
return t.AltCommand
}
return fmt.Sprintf("dokku --rm run --cron-id %s %s %s", t.ID, t.App, t.Command)
return fmt.Sprintf("dokku run --cron-id %s %s %s", t.ID, t.App, t.Command)
}
func fetchCronEntries(appName string) ([]templateCommand, error) {

16
plugins/run/commands Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env bash
[[ " help run:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
source "$PLUGIN_AVAILABLE_PATH/run/help-functions"
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
case "$1" in
help | run:help)
cmd-run-help "$@"
;;
*)
exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
;;
esac

34
plugins/run/help-functions Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
cmd-run-help() {
declare desc="help command"
declare CMD="$1"
local plugin_name="run"
local plugin_description="Run a one-off process inside a container"
if [[ "$CMD" == "${plugin_name}:help" ]]; then
echo -e "Usage: dokku ${plugin_name}[:COMMAND]"
echo ''
echo "$plugin_description"
echo ''
echo 'Additional commands:'
fn-help-content | sort | column -c2 -t -s,
elif [[ $(ps -o command= $PPID) == *"--all"* ]]; then
fn-help-content
else
cat <<help_desc
$plugin_name, $plugin_description
help_desc
fi
}
fn-help-content() {
declare desc="return help content"
cat <<help_content
run [-e|--env KEY=VALUE] [--no-tty] <app> <cmd>, Run a command in a new container using the current app image
run:detached [-e|-env KEY=VALUE] [--no-tty] <app> <cmd>, Run a command in a new detached container using the current app image
run:list <app>, List all run containers for an app
help_content
}

View File

@@ -1,12 +1,11 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
[[ $DOKKU_TRACE ]] && set -x
fn-run() {
declare desc="runs command in container"
cmd-run() {
declare desc="runs command in container based on app image"
declare cmd="run"
[[ "$1" == "$cmd" ]] && shift 1
declare APP=""
local SCHEDULER_ID
declare -a RUN_ENV
@@ -18,6 +17,10 @@ cmd-run() {
SCHEDULER_ID+=("$arg")
shift
;;
--no-tty)
export DOKKU_DISABLE_TTY=true
shift
;;
--cron-id)
if [[ ! $2 ]]; then
dokku_log_warn "expected $1 to have an argument"
@@ -53,4 +56,32 @@ cmd-run() {
DOKKU_CRON_ID="$CRON_ID" plugn trigger scheduler-run "$DOKKU_SCHEDULER" "$APP" "${#RUN_ENV[@]}" "${RUN_ENV[@]}" "$@"
}
cmd-run "$@"
cmd-run() {
declare desc="runs command in container based on app image"
declare cmd="run"
[[ "$1" == "$cmd" ]] && shift 1
export DOKKU_RM_CONTAINER=1
fn-run "$@"
}
cmd-run-detached() {
declare desc="run a detached container"
declare cmd="run:detached"
[[ "$1" == "$cmd" ]] && shift 1
export DOKKU_DETACH_CONTAINER=1
export DOKKU_DISABLE_TTY=true
export DOKKU_RM_CONTAINER=1
fn-run "$@"
}
cmd-run-list() {
declare desc="list all run containers for an app"
declare cmd="run:list"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1"
local DOKKU_SCHEDULER=$(get_app_scheduler "$APP")
plugn trigger scheduler-run-list "$DOKKU_SCHEDULER" "$APP"
}

4
plugins/run/plugin.toml Normal file
View File

@@ -0,0 +1,4 @@
[plugin]
description = "dokku core run plugin"
version = "0.24.10"
[plugin.config]

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
source "$PLUGIN_AVAILABLE_PATH/run/internal-functions"
[[ $DOKKU_TRACE ]] && set -x
cmd-run "$@"

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
source "$PLUGIN_AVAILABLE_PATH/run/internal-functions"
[[ $DOKKU_TRACE ]] && set -x
cmd-run-detached "$@"

6
plugins/run/subcommands/list Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail
source "$PLUGIN_AVAILABLE_PATH/run/internal-functions"
[[ $DOKKU_TRACE ]] && set -x
cmd-run-list "$@"

View File

@@ -31,15 +31,17 @@ trigger-scheduler-docker-local-scheduler-run() {
local DOCKER_ARGS=$(: | plugn trigger docker-args-run "$APP" "$IMAGE_TAG")
[[ "$DOKKU_TRACE" ]] && DOCKER_ARGS+=" -e TRACE=true "
local PROCESS_TYPE=run
if [[ -n "$DOKKU_CRON_ID" ]]; then
PROCESS_TYPE=cron
DOCKER_ARGS+=" --label=com.dokku.cron-id=$DOKKU_CRON_ID"
fi
local DYNO_NUMBER="$RANDOM"
local IMAGE_SOURCE_TYPE="dockerfile"
is_image_herokuish_based "$IMAGE" "$APP" && IMAGE_SOURCE_TYPE="herokuish"
DOCKER_ARGS+=$(: | plugn trigger docker-args-process-run "$APP" "$IMAGE_SOURCE_TYPE" "$IMAGE_TAG")
DOCKER_ARGS+=" -e DYNO=run.$DYNO_NUMBER --name $APP.run.$DYNO_NUMBER"
if [[ -n "$DOKKU_CRON_ID" ]]; then
DOCKER_ARGS+=" --label=com.dokku.cron-id=$DOKKU_CRON_ID"
fi
DOCKER_ARGS+=" -e DYNO=$PROCESS_TYPE.$DYNO_NUMBER --name $APP.$PROCESS_TYPE.$DYNO_NUMBER"
declare -a ARG_ARRAY
eval "ARG_ARRAY=($DOCKER_ARGS)"
@@ -75,7 +77,7 @@ trigger-scheduler-docker-local-scheduler-run() {
fi
# shellcheck disable=SC2086
CONTAINER_ID="$("$DOCKER_BIN" container create --label=com.dokku.container-type=run "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS "${DOCKER_ARGS_ARRAY[@]}" $IMAGE $EXEC_CMD "$@")"
CONTAINER_ID="$("$DOCKER_BIN" container create --label=com.dokku.container-type=$PROCESS_TYPE "${DOCKER_RUN_LABEL_ARGS[@]}" $DOKKU_GLOBAL_RUN_ARGS "${DOCKER_ARGS_ARRAY[@]}" $IMAGE $EXEC_CMD "$@")"
plugn trigger post-container-create "app" "$CONTAINER_ID" "$APP" "run"
declare -a DOCKER_START_ARGS_ARRAY

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eo pipefail
[[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/config/functions"
trigger-scheduler-docker-local-scheduler-run() {
declare desc="runs command in container based on app image"
declare trigger="scheduler-run"
declare DOKKU_SCHEDULER="$1" APP="$2"
verify_app_name "$APP"
if [[ "$DOKKU_SCHEDULER" != "docker-local" ]]; then
return
fi
dokku_log_info2_quiet "$APP run containers"
docker ps --filter "label=com.dokku.app-name=$APP" --filter "label=com.dokku.container-type=run" --format "table {{.Names}}\t{{.Command}}\t{{.RunningFor}}"
}
trigger-scheduler-docker-local-scheduler-run "$@"

View File

@@ -60,7 +60,7 @@ teardown() {
assert_output_contains "entrypoint script started with arguments touch /app/predeploy.test"
assert_success
run /bin/bash -c "dokku --rm run $TEST_APP ls /app/predeploy.test"
run /bin/bash -c "dokku run $TEST_APP ls /app/predeploy.test"
echo "output: $output"
echo "status: $status"
assert_success

View File

@@ -31,12 +31,12 @@ teardown() {
assert_success
assert_output '["/start","web"]'
run /bin/bash -c "dokku --rm run $TEST_APP ls /app/prebuild.test"
run /bin/bash -c "dokku run $TEST_APP ls /app/prebuild.test"
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku --rm run $TEST_APP ls /app/predeploy.test"
run /bin/bash -c "dokku run $TEST_APP ls /app/predeploy.test"
echo "output: $output"
echo "status: $status"
assert_success

View File

@@ -11,7 +11,6 @@ setup() {
teardown() {
rm -rf /home/dokku/$TEST_APP/tls
destroy_app
dokku config:unset --global DOKKU_RM_CONTAINER
rm -f "$DOCKERFILE"
global_teardown
}
@@ -27,7 +26,7 @@ teardown() {
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
echo "output: $output"
echo "status: $status"
assert_success
assert_failure
RANDOM_RUN_CID="$(docker run -d gliderlabs/herokuish bash)"
docker ps -a
@@ -37,12 +36,6 @@ teardown() {
assert_success
sleep 5 # wait for dokku cleanup to happen in the background
docker ps -a
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "docker inspect $RANDOM_RUN_CID"
echo "output: $output"
echo "status: $status"

View File

@@ -20,26 +20,6 @@ teardown() {
assert_output_contains "Cleans up exited/dead Docker containers and removes dangling image"
}
@test "(core) run (with --options)" {
deploy_app
run /bin/bash -c "dokku --force --quiet run $TEST_APP python -V"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(core) run (with --env / -e)" {
deploy_app
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST=testvalue'"
echo "output: $output"
echo "status: $status"
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST2=testvalue2'"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(core) unknown command" {
run /bin/bash -c "dokku fakecommand"
echo "output: $output"

View File

@@ -175,24 +175,24 @@ EOF
assert_success
assert_output "true"
run /bin/bash -c "dokku --rm run $TEST_APP console"
run /bin/bash -c "dokku run $TEST_APP console"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "Hello world!"
run /bin/bash -c "dokku --rm run $TEST_APP printenv FOO"
run /bin/bash -c "dokku run $TEST_APP printenv FOO"
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku --rm config:set $TEST_APP FOO=bar"
run /bin/bash -c "dokku config:set $TEST_APP FOO=bar"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "Releasing $TEST_APP"
run /bin/bash -c "dokku --rm run $TEST_APP printenv FOO"
run /bin/bash -c "dokku run $TEST_APP printenv FOO"
echo "output: $output"
echo "status: $status"
assert_success

40
tests/unit/run_1.bats Normal file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env bats
load test_helper
setup() {
global_setup
create_app
}
teardown() {
destroy_app
global_teardown
}
@test "(run) run:help" {
run /bin/bash -c "dokku run:help"
echo "output: $output"
echo "status: $status"
assert_output_contains "Run a one-off process inside a container"
}
@test "(run) run (with --options)" {
deploy_app
run /bin/bash -c "dokku --force --quiet run $TEST_APP python -V"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(run) run (with --env / -e)" {
deploy_app
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST=testvalue'"
echo "output: $output"
echo "status: $status"
run /bin/bash -c "dokku run --env TEST=testvalue -e TEST2=testvalue2 $TEST_APP env | grep -E '^TEST2=testvalue2'"
echo "output: $output"
echo "status: $status"
assert_success
}

View File

@@ -5,72 +5,31 @@ load test_helper
setup() {
global_setup
create_app
DOCKERFILE="$BATS_TMPDIR/Dockerfile"
}
teardown() {
rm -rf /home/dokku/$TEST_APP/tls
destroy_app
dokku config:unset --global DOKKU_RM_CONTAINER
rm -f "$DOCKERFILE"
global_teardown
}
@test "(core) run (with DOKKU_RM_CONTAINER/--rm-container)" {
@test "(core) run" {
deploy_app
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
run /bin/bash -c "dokku run $TEST_APP echo $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku config:set --no-restart $TEST_APP DOKKU_RM_CONTAINER=1"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku config:unset --no-restart $TEST_APP DOKKU_RM_CONTAINER"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku config:set --global DOKKU_RM_CONTAINER=1"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku --rm-container run $TEST_APP echo $TEST_APP"
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "docker ps -a -f 'status=exited' --no-trunc=true | grep \"/exec echo $TEST_APP\""
echo "output: $output"
echo "status: $status"
assert_failure
run /bin/bash -c "dokku config:unset --global DOKKU_RM_CONTAINER"
echo "output: $output"
echo "status: $status"
assert_success
}
@test "(core) run (detached)" {
@test "(core) run:detached" {
deploy_app
RANDOM_RUN_CID="$(dokku --label=com.dokku.test-label=value --detach run $TEST_APP sleep 300)"
RANDOM_RUN_CID="$(dokku --label=com.dokku.test-label=value run:detached $TEST_APP sleep 300)"
run /bin/bash -c "docker inspect -f '{{ .State.Status }}' $RANDOM_RUN_CID"
echo "output: $output"
echo "status: $status"