Attach new interactive bash shell to runnig docker container
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
# to attach new bash sessions to docker container | |
# assumes that only one container is active, finds that containers id and attaches a new bash shell to it.. | |
attach_new_sess () { | |
sudo docker ps; | |
containerid=$(sudo docker ps | tail -1 | awk '{print $1}'); | |
echo "Extracted CONAINER ID: $containerid"; | |
echo "Spawning new bash shell in container..." | |
sudo docker exec -it $containerid bash; | |
} | |
alias ans='attach_new_sess' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment