Skip to content

Instantly share code, notes, and snippets.

@frietz58
Last active May 11, 2022 09:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Attach new interactive bash shell to runnig docker container
# 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