Skip to content

Instantly share code, notes, and snippets.

@cbfn
Last active March 2, 2023 17:09
Show Gist options
  • Save cbfn/be2fdaccfaf0d16faae64e0dcd152650 to your computer and use it in GitHub Desktop.
Save cbfn/be2fdaccfaf0d16faae64e0dcd152650 to your computer and use it in GitHub Desktop.
Getting docker container id
# Don't forget to change <text> with the search term
#!/bin/bash
DOCKER_CONTAINER_NAME="container name or other text"
DOCKER_CONTAINER="$(docker ps | grep $DOCKER_CONTAINER_NAME | awk '{print $1;}')"
DOCKER_RUN_CONSOLE="docker exec -it $DOCKER_CONTAINER /bin/bash"
ascii_name() {
cat <<"EOT"
_ _ _
| | | | | |
__| | ___ ___ | | __ ___ _ __ ___ ___ _ __ ___ ___ | | ___
/ _` | / _ \ / __|| |/ / / _ \| '__| / __| / _ \ | '_ \ / __| / _ \ | | / _ \
| (_| || (_) || (__ | < | __/| | | (__ | (_) || | | |\__ \| (_) || || __/
\__,_| \___/ \___||_|\_\ \___||_| \___| \___/ |_| |_||___/ \___/ |_| \___|
EOT
}
ascii_name
eval $DOCKER_RUN_CONSOLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment