Skip to content

Instantly share code, notes, and snippets.

@refo
Created December 6, 2022 11:08
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 refo/203d921e066c1893d60736c576a0dfe1 to your computer and use it in GitHub Desktop.
Save refo/203d921e066c1893d60736c576a0dfe1 to your computer and use it in GitHub Desktop.
Docker exec by name: Search containers by name and exec on the first container
NAME=someapp_api; CMD=bash; docker exec -it `docker ps -f name="${NAME}" --format '{{.ID}}' | head -n 1` ${CMD}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment