Page MenuHomePhabricator
Paste P12037

(An Untitled Masterwork)
ActivePublic

Authored by jbond on Fri, Jul 24, 1:30 PM.
function docker-debian {
docker run --rm -it debian:${1} /bin/bash
}
function docker-killall {
for i in $(docker ps --all | tail +2 | awk '{print $1}')
do
docker stop ${i} || docker kill ${i}
docker rm ${i}
done
}
function docker-bash {
# Fuck knows how this works, zsh voodoo
OPTIONS=("${(f)$(docker ps | tail +2)}")
if [ -z ${1+x} ]
then
if [ -z ${OPTIONS} ]
then
echo "No containers running"
return
elif [ ${#OPTIONS[@]} -eq 1 ]
then
local CONTAINER=${${(z)OPTIONS[1]}[1]}
else
COUNT=1
for line in ${OPTIONS}
do
echo "[${COUNT}]: ${line}"
COUNT=$((COUNT+1))
done
echo "Please select container to connect too [1-${#OPTIONS[@]}]"
read ans
if [ ${ans} -gt ${#OPTIONS[@]} ]
then
echo "Invalid selection"
return
else
local CONTAINER=${${(z)OPTIONS[${ans}]}[1]}
fi
fi
else
local CONTAINER=${1}
fi
docker exec -i -t ${CONTAINER} /bin/bash
}

Event Timeline

jbond created this paste.Fri, Jul 24, 1:30 PM