Created
April 28, 2025 13:32
-
-
Save Horat1us/f0d8390dc52d918c432bbb8a8c5ddf98 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| dockerin() { | |
| pattern=$1 | |
| container_id=$(docker ps --format "{{.ID}}\t{{.Image}}" | grep -i "$pattern" | head -n 1 | awk '{print $1}') | |
| if [ -z "$container_id" ]; then | |
| echo "No running container found with image matching: $pattern" | |
| return 1 | |
| fi | |
| echo "Executing into container: $container_id ($(docker ps --no-trunc --format "{{.Image}}" --filter "id=$container_id"))" | |
| docker exec -it $container_id sh | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add to ~/.bashrc and use it like: