Add the ability to enter a running container
This commit is contained in:
@@ -21,6 +21,7 @@ mysql:clone <name> <new-name> Create container <new-name> then copy data from <
|
|||||||
mysql:connect <name> Connect via mysql to a mysql service
|
mysql:connect <name> Connect via mysql to a mysql service
|
||||||
mysql:create <name> Create a mysql service with environment variables
|
mysql:create <name> Create a mysql service with environment variables
|
||||||
mysql:destroy <name> Delete the service and stop its container if there are no links left
|
mysql:destroy <name> Delete the service and stop its container if there are no links left
|
||||||
|
mysql:enter <name> [command] Enter a running couchdb service or run a command
|
||||||
mysql:export <name> > <file> Export a dump of the mysql service database
|
mysql:export <name> > <file> Export a dump of the mysql service database
|
||||||
mysql:expose <name> [port] Expose a mysql service on custom port if provided (random port otherwise)
|
mysql:expose <name> [port] Expose a mysql service on custom port if provided (random port otherwise)
|
||||||
mysql:import <name> < <file> Import a dump into the mysql service database
|
mysql:import <name> < <file> Import a dump into the mysql service database
|
||||||
@@ -71,6 +72,14 @@ dokku mysql:info lolipop --service-root
|
|||||||
dokku mysql:info lolipop --status
|
dokku mysql:info lolipop --status
|
||||||
dokku mysql:info lolipop --version
|
dokku mysql:info lolipop --version
|
||||||
|
|
||||||
|
# a bash prompt can be opened against a running service
|
||||||
|
# filesystem changes will not be saved to disk
|
||||||
|
dokku mysql:enter lolipop
|
||||||
|
|
||||||
|
# you may also run a command directly against the service
|
||||||
|
# filesystem changes will not be saved to disk
|
||||||
|
dokku mysql:enter lolipop ls -lah /
|
||||||
|
|
||||||
# a mysql service can be linked to a
|
# a mysql service can be linked to a
|
||||||
# container this will use native docker
|
# container this will use native docker
|
||||||
# links via the docker-options plugin
|
# links via the docker-options plugin
|
||||||
|
|||||||
@@ -102,6 +102,21 @@ service_alternative_alias() {
|
|||||||
echo "$ALIAS"
|
echo "$ALIAS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service_enter() {
|
||||||
|
declare desc="enters running app container of specified proc type"
|
||||||
|
declare SERVICE="$1" && shift 1
|
||||||
|
local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||||
|
local ID="$(cat "$SERVICE_ROOT/ID")"
|
||||||
|
|
||||||
|
docker inspect "$ID" &> /dev/null || dokku_log_fail "Container does not exist"
|
||||||
|
is_container_status "$ID" "Running" || dokku_log_fail "Container is not running"
|
||||||
|
|
||||||
|
local EXEC_CMD=""
|
||||||
|
has_tty && local DOKKU_RUN_OPTS+=" -i -t"
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
docker exec $DOKKU_RUN_OPTS $ID $EXEC_CMD "${@:-/bin/bash}"
|
||||||
|
}
|
||||||
|
|
||||||
service_exposed_ports() {
|
service_exposed_ports() {
|
||||||
declare desc="Lists exposed ports for a service"
|
declare desc="Lists exposed ports for a service"
|
||||||
declare SERVICE="$1"
|
declare SERVICE="$1"
|
||||||
|
|||||||
16
subcommands/enter
Executable file
16
subcommands/enter
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||||
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
||||||
|
source "$PLUGIN_BASE_PATH/common/functions"
|
||||||
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||||
|
|
||||||
|
enter-cmd() {
|
||||||
|
declare desc="enter a running $PLUGIN_SERVICE service or run a command"
|
||||||
|
local cmd="$PLUGIN_COMMAND_PREFIX:enter" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||||
|
declare SERVICE="$1" && shift 1
|
||||||
|
|
||||||
|
dokku_log_info1_quiet "Filesystem changes may not persist after container restarts"
|
||||||
|
service_enter "$SERVICE" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
enter-cmd "$@"
|
||||||
Reference in New Issue
Block a user