Skip to content

Instantly share code, notes, and snippets.

@frietz58
Last active May 11, 2022 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frietz58/25d4373c77afed54e5248d83dc5cac25 to your computer and use it in GitHub Desktop.
Save frietz58/25d4373c77afed54e5248d83dc5cac25 to your computer and use it in GitHub Desktop.
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