Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
list of lines in my bashrc to make docker use much more simple
#docker stuff.. move into own file
#Docker alias's
alias dpsa="docker ps -a"
alias dps="docker ps"
#docker envs
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/andrew/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
echo ".bashrc boot2docker command results: (Should see 3 lines:)"
(boot2docker shellinit)
combinedhelp(){
echo "
D --replacement for 'docker' EG: D images = docker images
combinedhelp -- prints description of docker helper funcitions
b2dhelp = combinedhelp
b2d = substitutes b2d with boot2docker
b2drebuild -- rebuilds the boot2docker virtual machine:
boot2docker poweroff
boot2docker delete
boot2docker init
boot2docker up
dhelp = combinedhelp
drm = docker rm [args]
drmi -- Removes docker images based on args passed in
- If 'none' passed in docker rmi on all images with <none>
- else docker rmi [args]
dstart = docker start [args]
dstop = docker stop [args]
dkill = docker kill [args]
dpersist = docker run -t -i -d [arg]
dattach = docker attach [arg]
dpa -- runs dpersist and pipes result into dattach
dbuild -- builds docker file in current dir with the following:
- uses pwd basename as image name
- If 1 arg: arg is version number
- If 2 args:
- arg 1: prefix before basename (forward slash added)
- arg1/basename
- arg 2: version number
dps = docker ps
dpsa = docker ps -a
dimg = docker images
"
}
b2dhelp(){
combinedhelp
}
b2d(){
boot2docker $@
}
b2drebuild(){
boot2docker poweroff
boot2docker delete
boot2docker init
boot2docker up
}
dhelp(){
combinedhelp
}
drm(){
docker rm $@
}
drmi(){
if [ "$1" == "none" ]; then
docker rmi $(docker images | grep "<none>" | awk '{print $3}')
else
docker rmi $@
fi
}
drminone(){
docker rmi $(docker images | grep "<none>" | awk '{print $3}')
}
dstart(){
docker start $@
}
dstop(){
docker stop $@
}
dkill(){
docker kill $@
}
dpersist(){
docker run -t -i -d $1
}
dattach(){
docker attach $1
}
dpa(){ #combination of dpersist and dattach
C=$(dpersist $1)
dattach $C
}
# if 1 arg the arg is version number
# if 2 arg then arg1 prefix before current directory basename eg arg1/basename
# and arg2 is version number
dbuild(){
#docker build -t `basename $(pwd)` ./.
if [ -n "$1" ] && [ -n "$2" ]; then
docker build -t $1/`basename $(pwd)`:$2 ./.
docker tag $1/`basename $(pwd)`:$2 $1/`basename $(pwd)`:latest
elif [ -n "$1" ]; then
docker build -t `basename $(pwd)`:$1 ./.
docker tag `basename $(pwd)`:$1 `basename $(pwd)`:latest
else
docker build -t `basename $(pwd)` ./.
fi
}
dimg(){
docker images $@
}
D(){
docker $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.