Skip to content

Instantly share code, notes, and snippets.

@mkamrani
Created October 3, 2019 02:15
Show Gist options
  • Save mkamrani/81107f6d09b05c41db9026810333666a to your computer and use it in GitHub Desktop.
Save mkamrani/81107f6d09b05c41db9026810333666a to your computer and use it in GitHub Desktop.
A handy alias to execute a command inside a docker container with a specific name (interactive mode)
# put this in ~/.bashrc, or ~/.zshrc, etc., then source ~/.bashrc or source ~/.zshrc
# Use it like dexec <containername> <command> : dexec node bash
dexec() {
name=${1}
command=${2}
docker exec -ti $(docker ps | grep $name | awk '{print $1}') $command
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment