Last active
December 15, 2021 20:32
-
-
Save itailulu/088738595db85e6a5eb29e649c54957e to your computer and use it in GitHub Desktop.
Interactively bash into a docker container, without having to type it's full name - just pick its number!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dbsh() { | |
docker ps --format '{{.Names}}' | nl -s ") " | |
echo "Pick container" | |
read CONTAINER | |
CONTAINER_NAME=$(docker ps --format '{{.Names}}' | sed -n "${CONTAINER}p") | |
docker exec -ti $CONTAINER_NAME /bin/bash | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put this in your
.zshrc
(or.bashrc
) file, and enjoy