Last active
September 10, 2018 00:49
-
-
Save zouchao/eb21fee72f91ec1c6dde2c6b164097bb to your computer and use it in GitHub Desktop.
login rancher docker container
This file contains hidden or 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
echo '#!/bin/bash | |
command="docker ps" | |
for arg in $@; do | |
command="$command | grep $arg" | |
done | |
command="$command | grep -v haproxy | head -1" | |
if [[ `eval $command` =~ "piledriver" ]]; then | |
entrance="/bin/sh" | |
else | |
entrance="/bin/bash" | |
fi | |
container_id=`eval $command | cut -c1-12` | |
echo "$container_id" | |
if [ -z "$container_id" ]; then | |
echo "Not Found~" | |
else | |
docker exec -it $container_id $entrance | |
fi' > ~/tp | |
chmod +x ~/tp | |
echo 'alias tp="sudo ~/tp"' >> ~/.bashrc | |
source ~/.bashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment