diff --git a/docs/appendices/0.25.0-migration-guide.md b/docs/appendices/0.25.0-migration-guide.md
index 1e75ddbf8..ac70f9252 100644
--- a/docs/appendices/0.25.0-migration-guide.md
+++ b/docs/appendices/0.25.0-migration-guide.md
@@ -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.
diff --git a/docs/configuration/environment-variables.md b/docs/configuration/environment-variables.md
index 70d5b6227..2914a6d03 100644
--- a/docs/configuration/environment-variables.md
+++ b/docs/configuration/environment-variables.md
@@ -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`
`~dokku/.dokkurc`
`~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`
`~dokku/.dokkurc`
`~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`
`~dokku/.dokkurc`
`~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`
`--rm-container` flag
`--rm` flag | Whether to keep `dokku run` containers around or not. |
-| `DOKKU_TRACE` | none | `dokku trace:on`
`dokku trace:off`
`--trace` flag | Turn on very verbose debugging. |
+| `DOKKU_RM_CONTAINER` | none | `dokku config:set`
| Deprecated: Whether to keep `dokku run` containers around or not. |
+| `DOKKU_TRACE` | none | `dokku trace:on`
`dokku trace:off`
`--trace` flag | Turn on very verbose debugging. |
| `DOKKU_APP_PROXY_TYPE` | `nginx` | `dokku proxy:set` | |
| `DOKKU_APP_RESTORE` | `1` | `dokku config:set`
`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. |
diff --git a/docs/deployment/remote-commands.md b/docs/deployment/remote-commands.md
index 33a912cae..0ad87480c 100644
--- a/docs/deployment/remote-commands.md
+++ b/docs/deployment/remote-commands.md
@@ -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
--force force flag. currently used in apps:destroy and other ":destroy" commands
```
diff --git a/docs/processes/one-off-tasks.md b/docs/processes/one-off-tasks.md
index d2dd02ac8..a028b1c82 100644
--- a/docs/processes/one-off-tasks.md
+++ b/docs/processes/one-off-tasks.md
@@ -1,23 +1,31 @@
# One-off Tasks
```
-run [ --env KEY=VALUE | -e KEY=VALUE ] # Run a command in a new container using the current application image
+run [-e|--env KEY=VALUE] [--no-tty] # Run a command in a new container using the current app image
+run:detached [-e|-env KEY=VALUE] [--no-tty] # Run a command in a new detached container using the current app image
+run:list [] # 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.
diff --git a/dokku b/dokku
index 59b712280..4d1ee02df 100755
--- a/dokku
+++ b/dokku
@@ -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 [command-specific-options]"
+ dokku_log_quiet "Usage: dokku [--quiet|--trace|--force] COMMAND [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 ""
diff --git a/plugins/00_dokku-standard/commands b/plugins/00_dokku-standard/commands
index 56b37905c..ace188e6d 100755
--- a/plugins/00_dokku-standard/commands
+++ b/plugins/00_dokku-standard/commands
@@ -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 "$@"
;;
diff --git a/plugins/00_dokku-standard/help-functions b/plugins/00_dokku-standard/help-functions
index 2c8bceef3..7f9f22b54 100755
--- a/plugins/00_dokku-standard/help-functions
+++ b/plugins/00_dokku-standard/help-functions
@@ -18,7 +18,6 @@ fn-help-content() {
declare desc="return help content"
cat <], Cleans up exited/dead Docker containers and removes dangling images
- run [--env KEY=VALUE] , Run a command in a new container using the current application image
url , Show the first URL for an application (compatibility)
urls , Show all URLs for an application
version , Print dokku's version
diff --git a/plugins/20_events/scheduler-run-list b/plugins/20_events/scheduler-run-list
new file mode 120000
index 000000000..5178a749f
--- /dev/null
+++ b/plugins/20_events/scheduler-run-list
@@ -0,0 +1 @@
+hook
\ No newline at end of file
diff --git a/plugins/common/functions b/plugins/common/functions
index 01353900a..8191c2773 100755
--- a/plugins/common/functions
+++ b/plugins/common/functions
@@ -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
diff --git a/plugins/cron/functions.go b/plugins/cron/functions.go
index 4ce0c349c..f09192b3f 100644
--- a/plugins/cron/functions.go
+++ b/plugins/cron/functions.go
@@ -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) {
diff --git a/plugins/run/commands b/plugins/run/commands
new file mode 100755
index 000000000..3096db561
--- /dev/null
+++ b/plugins/run/commands
@@ -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
diff --git a/plugins/run/help-functions b/plugins/run/help-functions
new file mode 100755
index 000000000..e8e41f6c4
--- /dev/null
+++ b/plugins/run/help-functions
@@ -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 < , Run a command in a new container using the current app image
+ run:detached [-e|-env KEY=VALUE] [--no-tty] , Run a command in a new detached container using the current app image
+ run:list , List all run containers for an app
+help_content
+}
diff --git a/plugins/00_dokku-standard/subcommands/run b/plugins/run/internal-functions
similarity index 65%
rename from plugins/00_dokku-standard/subcommands/run
rename to plugins/run/internal-functions
index 0cfd97888..0a624f811 100755
--- a/plugins/00_dokku-standard/subcommands/run
+++ b/plugins/run/internal-functions
@@ -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"
+}
diff --git a/plugins/run/plugin.toml b/plugins/run/plugin.toml
new file mode 100644
index 000000000..3ded5e429
--- /dev/null
+++ b/plugins/run/plugin.toml
@@ -0,0 +1,4 @@
+[plugin]
+description = "dokku core run plugin"
+version = "0.24.10"
+[plugin.config]
diff --git a/plugins/run/subcommands/default b/plugins/run/subcommands/default
new file mode 100755
index 000000000..66d4a5dd7
--- /dev/null
+++ b/plugins/run/subcommands/default
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -eo pipefail
+source "$PLUGIN_AVAILABLE_PATH/run/internal-functions"
+[[ $DOKKU_TRACE ]] && set -x
+
+cmd-run "$@"
diff --git a/plugins/run/subcommands/detached b/plugins/run/subcommands/detached
new file mode 100755
index 000000000..637af4a18
--- /dev/null
+++ b/plugins/run/subcommands/detached
@@ -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 "$@"
diff --git a/plugins/run/subcommands/list b/plugins/run/subcommands/list
new file mode 100755
index 000000000..d24947806
--- /dev/null
+++ b/plugins/run/subcommands/list
@@ -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 "$@"
diff --git a/plugins/scheduler-docker-local/scheduler-run b/plugins/scheduler-docker-local/scheduler-run
index 81cc35edd..2cbbb872c 100755
--- a/plugins/scheduler-docker-local/scheduler-run
+++ b/plugins/scheduler-docker-local/scheduler-run
@@ -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
diff --git a/plugins/scheduler-docker-local/scheduler-run-list b/plugins/scheduler-docker-local/scheduler-run-list
new file mode 100755
index 000000000..1bea78c9c
--- /dev/null
+++ b/plugins/scheduler-docker-local/scheduler-run-list
@@ -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 "$@"
diff --git a/tests/unit/app-json-2.bats b/tests/unit/app-json-2.bats
index 88efdded1..c3fdd2d67 100644
--- a/tests/unit/app-json-2.bats
+++ b/tests/unit/app-json-2.bats
@@ -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
diff --git a/tests/unit/app-json.bats b/tests/unit/app-json.bats
index 09aa65597..39f406bd9 100644
--- a/tests/unit/app-json.bats
+++ b/tests/unit/app-json.bats
@@ -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
diff --git a/tests/unit/core_1.bats b/tests/unit/core_1.bats
index fdaa43765..a712916b5 100644
--- a/tests/unit/core_1.bats
+++ b/tests/unit/core_1.bats
@@ -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"
diff --git a/tests/unit/core_2.bats b/tests/unit/core_2.bats
index 57dfe1fad..ab699655d 100644
--- a/tests/unit/core_2.bats
+++ b/tests/unit/core_2.bats
@@ -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"
diff --git a/tests/unit/ps-general.bats b/tests/unit/ps-general.bats
index 0fed2d3fc..cd237b151 100644
--- a/tests/unit/ps-general.bats
+++ b/tests/unit/ps-general.bats
@@ -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
diff --git a/tests/unit/run_1.bats b/tests/unit/run_1.bats
new file mode 100644
index 000000000..2b16b4943
--- /dev/null
+++ b/tests/unit/run_1.bats
@@ -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
+}
diff --git a/tests/unit/core_3.bats b/tests/unit/run_2.bats
similarity index 50%
rename from tests/unit/core_3.bats
rename to tests/unit/run_2.bats
index 66c271d3f..0be97ab67 100644
--- a/tests/unit/core_3.bats
+++ b/tests/unit/run_2.bats
@@ -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"