diff --git a/docs/appendices/0.25.0-migration-guide.md b/docs/appendices/0.25.0-migration-guide.md index 1e75ddbf8..f94cea26c 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`. diff --git a/docs/configuration/environment-variables.md b/docs/configuration/environment-variables.md index 70d5b6227..09a4473e2 100644 --- a/docs/configuration/environment-variables.md +++ b/docs/configuration/environment-variables.md @@ -94,7 +94,7 @@ The following config variables have special meanings and can be set in a variety | `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_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_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` | | 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..c4e5483d5 100644 --- a/docs/processes/one-off-tasks.md +++ b/docs/processes/one-off-tasks.md @@ -8,7 +8,7 @@ Sometimes it is necessary to run a one-off command under an application. Dokku m ## 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. +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. This contianer will be removed after the process exits. The container image will be the same container image as was used to start the currently deployed application. ```shell # runs `ls -lah` in the `/app` directory of the application `node-js-app` @@ -29,23 +29,6 @@ console: bundle exec racksh 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 -``` - 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`. ```shell diff --git a/dokku b/dokku index c90749787..4d1ee02df 100755 --- a/dokku +++ b/dokku @@ -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/common/functions b/plugins/common/functions index 01353900a..bfe8c2757 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -439,7 +439,7 @@ parse_args() { 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/internal-functions b/plugins/run/internal-functions index 814ce6cf5..977a23903 100755 --- a/plugins/run/internal-functions +++ b/plugins/run/internal-functions @@ -57,5 +57,6 @@ cmd-run() { declare cmd="run" [[ "$1" == "$cmd" ]] && shift 1 + export DOKKU_RM_CONTAINER=1 fn-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..c0d07f053 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 } 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 index 7dd8fe9b2..2b16b4943 100644 --- a/tests/unit/run_1.bats +++ b/tests/unit/run_1.bats @@ -9,7 +9,6 @@ setup() { teardown() { destroy_app - dokku config:unset --global DOKKU_RM_CONTAINER global_teardown } diff --git a/tests/unit/run_2.bats b/tests/unit/run_2.bats index f063edfe5..25994fcd5 100644 --- a/tests/unit/run_2.bats +++ b/tests/unit/run_2.bats @@ -9,59 +9,21 @@ setup() { teardown() { destroy_app - dokku config:unset --global DOKKU_RM_CONTAINER 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)" {