You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
493 B
23 lines
493 B
|
3 years ago
|
#!/bin/bash
|
||
|
|
|
||
|
|
# Config:
|
||
|
|
# alias dexec="bash $HOME/.myscript/docker_exec_by_name.sh"
|
||
|
|
|
||
|
|
# Usage:
|
||
|
|
# dexec redis
|
||
|
|
|
||
|
|
docker_exec_cmd() {
|
||
|
|
container_name=$1
|
||
|
|
container_id=`docker ps | grep "$container_name" | awk '{print $1}'`
|
||
|
|
if [ ${#container_id} -eq 12 ]; then
|
||
|
|
echo "CONTAINER [$container_id $container_name]"
|
||
|
|
docker exec -it $container_id bash
|
||
|
|
elif [ ${#container_id} -gt 12 ]; then
|
||
|
|
echo "MORE THEN ONE [$container_name]"
|
||
|
|
else
|
||
|
|
echo "NOT FOUND [$container_name]"
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
docker_exec_cmd $1
|