diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 710369b6c7..2c63b77da4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,8 @@ Changelog in development -------------- +* Detect Docker environment in `st2ctl` and guide users to use proper Docker commands instead of VM-style commands (#4988) - @Emu55 + Python 3.6 is no longer supported; Stackstorm requires at least Python 3.8. This release adds support for Python 3.10 and 3.11, so StackStorm supports python 3.8 - 3.11. diff --git a/st2common/bin/st2ctl b/st2common/bin/st2ctl index 9ed12ada4b..6dc1254e1b 100755 --- a/st2common/bin/st2ctl +++ b/st2common/bin/st2ctl @@ -69,6 +69,24 @@ function must_be_root() { fi } +# -- Detect whether running inside a Docker container -- +function running_in_docker() { + [ -f /.dockerenv ] && return 0 + return 1 +} + +# Tell the user to use Docker commands instead of st2ctl +function suggest_docker_usage() { + echo -e "\e[31mError: “st2ctl $1” is not supported inside Docker.\e[0m" + echo "" + echo "Please manage StackStorm services with Docker commands, e.g.:" + echo " docker ps" + echo " docker-compose restart st2api" + echo " docker-compose logs -f st2stream" + exit 1 +} + + function not_running_in_k8s() { if [ -n "$KUBERNETES_SERVICE_HOST" ]; then echo -e "\e[31mError: \"st2ctl status\" is not supported under Kubernetes, please use Kubernetes tools such as \"kubectl\" to view the StackStorm services in this cluster. \e[0m\n" @@ -213,6 +231,15 @@ function getpids() { done } +# If in Docker, refuse any of the VM‐style commands +if running_in_docker; then + case "$1" in + status) + suggest_docker_usage "$1" + ;; + esac +fi + case ${1} in start)