Last active
August 29, 2015 14:24
-
-
Save tym-xqo/cfc4e13328a444132745 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Standard `docker exec -t` doesn't create a full tty, and has no $TERM set. | |
# This creates problems for me sometimes (I like the `clear` command, and | |
# psql complains a bit if the client is not a functional terminal). | |
# I do the command below enough that I made this script. | |
# Pass it the name or ID of a running container, and Bob's your uncle. | |
while true; | |
do | |
case $1 in | |
-e) | |
cid=$(docker ps | grep $2 | grep -v pause | cut -f 1 -d' ') | |
docker exec -it $cid script -f /dev/null -c "export TERM=xterm && /bin/bash" | |
break | |
;; | |
*) | |
cid=$(docker ps | grep $1 | grep -v pause | cut -f 1 -d' ') | |
echo $cid; break | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So, I put a symlink to this in my $PATH, and then I can go
exectty postgres
or whatever and I'm in with a more functional terminal than bareexec /bin/bash
gives you, and I don't even have to look up the container ID.