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