Skip to content

Instantly share code, notes, and snippets.

@hershkoy
Last active May 25, 2021 19:34
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 hershkoy/7d5a2c3c45f6233660bbbfe534073a4b to your computer and use it in GitHub Desktop.
Save hershkoy/7d5a2c3c45f6233660bbbfe534073a4b to your computer and use it in GitHub Desktop.
docker exec/ssh into container by the row number in docker ps -a
#!/bin/bash
ln="$1"
containername=`docker ps --format "{{.Names}}" | awk "FNR == $1"`
echo $containername
docker exec -it $containername bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment