-
-
Save rimelek/f10d9e301f7686cd82938c5128ea7595 to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| set -eu -o pipefail | |
| function docker_desktop() { | |
| CONTEXT_DESC="Docker Desktop" | |
| DD_HOME="$HOME/.docker" | |
| export PATH="/usr/local/bin:$PATH" | |
| export DOCKER_CONTEXT=desktop-linux | |
| export DOCKER_CONFIG="$DD_HOME" | |
| container_desktop_shell | |
| } | |
| function rancher_desktop() { | |
| CONTEXT_DESC="Rancher Desktop" | |
| RD_HOME="$HOME/.rd" | |
| SOCKET_DIR="$RD_HOME" | |
| export PATH="$RD_HOME/bin:$PATH" | |
| export DOCKER_CONTEXT=rancher-desktop | |
| export DOCKER_CONFIG="$RD_HOME/docker" | |
| container_desktop_shell | |
| } | |
| function container_desktop_shell() { | |
| ( | |
| docker --context default context ls --quiet | grep "^$DOCKER_CONTEXT\$" \ | |
| || docker --context default context create "$DOCKER_CONTEXT" --description "$CONTEXT_DESC" --docker "host=unix://$SOCKET_DIR/docker.sock" | |
| ) 1>/dev/null | |
| exec $SHELL | |
| } | |
| shell_name="${1:-}" | |
| case "$shell_name" in | |
| docker) | |
| docker_desktop | |
| ;; | |
| rancher) | |
| rancher_desktop | |
| ;; | |
| *) | |
| >&2 echo "Valid container desktop shell names: docker, rancher" | |
| exit 1 | |
| ;; | |
| esac |
Hi. Did you forget to add the first line to run the script in Bash shell maybe? Or how do you run the script? If you for example run it like:
sh container-desktop-shell.sh
It will override the default shell defined in the first line and other shells might not recognize the function syntax I used for Bash.
OK, I should use bash container-desktop-shell.sh
So this don't solve my problem, docker desktop start but window is black
I use zsh on macOS, but the script itself runs in a bash shell. Then the exec $SHELL line is repsonsible for giving you the prompt in the original shell.
Regarding black window when starting Docker Desktop, that is indeed something this script would not solve. It just helps to use multiple docker clients and client configuration for two Rancher Desktop and Docker Desktop.
Docker Desktop issues could be reported in the docker/desktop-feedback repository,but we can also try to help you on the Docker Forum, although we often recommend the desktop-feedback repo at the end if we can't figure out the issue without the developers or it requires a bugfix.
Mi hanno già risposto; Docker dice che non funziona su Debian13 ma solo su Debian12.
errore alla linea 7 '('