diff --git a/modules/docker/README.md b/modules/docker/README.md index 3ba80032..d1d8caf3 100644 --- a/modules/docker/README.md +++ b/modules/docker/README.md @@ -6,8 +6,20 @@ Enables boot2docker and docker support. boot2docker ----------- +Will automatically set the environment if boot2docker is running. +- `b2d` boot2docker +- `b2dstart` start docker vm, set environment +- `b2dssh` ssh to the boot2docker vm +- `b2dstop` stop the boot2docker vm +- `b2di` show boot2docker status docker ------ +- `doc` docker +- `docp` docker ps +- `docpa` docker ps -a +- `docimg` show docker images +- `docbash` launch bash in an already running container + diff --git a/modules/docker/init.zsh b/modules/docker/init.zsh new file mode 100644 index 00000000..4b54cb55 --- /dev/null +++ b/modules/docker/init.zsh @@ -0,0 +1,35 @@ +# +# Defines docker and boot2docker commands & aliases +# +# Authors: +# andrew williams (https://github.com/skarfacegc) +# + +# Only setup the boot2docker commands and aliases if we're on OSX +if [[ "$OSTYPE" == darwin* ]]; then + + # Set environment if boot2docker is already running + if [[ $(boot2docker status) == "running" ]]; then + eval $(boot2docker shellinit 2> /dev/null) + fi + + alias b2d='boot2docker' + alias b2dstart='boot2docker start &> /dev/null && eval $(boot2docker shellinit 2> /dev/null)' + alias b2dstop='boot2docker stop' + alias b2dssh='boot2docker ssh' + alias b2di='boot2docker info' + +fi + + +# Docker alases +alias doc='docker' +alias docp='docker ps' +alias docpa='docker ps -a' +alias docimg='docker images' + +docbash() { + docker exec -t -i "$1" /bin/bash +} +compdef -e 'words[1]=(docker exec); service=docker; (( CURRENT+=1 )); _docker' docbash +