Save some time with Docker on Mac

Docker has a big power, but you pay the tax with long commands that have to run very often.

Docker Compose helps so much on this but anyway you need enter on the containers and commands are long, deal with docker-machine blablabla.

To avoid repeat a couple of task that you do so often add the shortcuts to .bash_profile like that:

~.bash_profile

dlog(){
   docker logs [email protected]
}

dlogf(){
   dlog -f [email protected]
}

wakeup(){
   docker-compose up [email protected]
}

enough(){
   docker-compose down [email protected]
}

enter(){
   docker exec -it $1 bash -l
}

connect(){
   eval $(docker-machine env ${1:-"default"})
}

ds(){
  docker service [email protected]
}

dst(){
  ds tasks [email protected]
}

dsr(){
  ds rm [email protected]
}

dsu(){
  ds update [email protected]
}

dm-up(){
   dm start ${1:-"default"}
}

dm-stop(){
   docker-machine stop ${1:-"default"}
}

dc(){
   connect ${1:-"default"};
   if (($? == 1)); then
        dm-up ${1:-"default"};
        connect ${1:-"default"};
   fi
}

dm(){
   docker-machine [email protected]
}

So, when you start:

$ connect

To up and down the project on docker-compose.yml folder:

$ wakeup
$ enough

To destroy the volumes too:

$ enough -v