Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
27 changes: 27 additions & 0 deletions st2common/bin/st2ctl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Loading