fix: dev container script container selection
This commit is contained in:
@@ -27,7 +27,7 @@ fi
|
||||
|
||||
echo "
|
||||
janishutz dev containers
|
||||
"
|
||||
"
|
||||
if [[ $(systemctl is-active docker) != "active" ]]; then
|
||||
echo "
|
||||
-> Docker daemon not running, starting with systemctl <-
|
||||
@@ -38,7 +38,7 @@ fi
|
||||
if [[ $1 == "rm" ]]; then
|
||||
echo "
|
||||
-> Removing containers with $name in their name <-
|
||||
"
|
||||
"
|
||||
if [[ $(read -p "Do you really want to delete ALL containers for this directory? (y/N) " response && echo $response) == 'y' ]]; then
|
||||
for container in $(docker container ls -aq -f name=$name); do
|
||||
docker stop $container
|
||||
@@ -63,27 +63,27 @@ elif [[ $1 == "shell" ]]; then
|
||||
elif [[ $count == 1 ]]; then
|
||||
echo "
|
||||
-> Connecting to running container ${containers[0]}
|
||||
"
|
||||
"
|
||||
docker exec -it ${containers[0]} '/bin/bash'
|
||||
else
|
||||
echo "
|
||||
-> Multiple possible containers found to attach to. Pick one (enter number)
|
||||
"
|
||||
docker ps -f name=$name
|
||||
read -p "Enter number (1-$(${#containers[@]})) " sel
|
||||
docker exec -it containers[$sel] '/bin/bash'
|
||||
read -p "Enter number (1-$count) " sel
|
||||
docker exec -it ${containers[$(($sel-1))]} '/bin/bash'
|
||||
fi
|
||||
else
|
||||
name=$name-$1
|
||||
if [[ $(docker container ls -aq -f name=$name) != "" ]]; then
|
||||
echo "
|
||||
-> Starting existing container $name <-
|
||||
"
|
||||
"
|
||||
docker start -i $name
|
||||
else
|
||||
echo "
|
||||
-> Creating container $name <-
|
||||
"
|
||||
"
|
||||
eval "${base_path}$1-container $name $mount_path"
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user