Skip to content

Instantly share code, notes, and snippets.

@neilellis
Last active August 29, 2015 14:27
Show Gist options
  • Save neilellis/41b1509bdf1636260c9a to your computer and use it in GitHub Desktop.
Save neilellis/41b1509bdf1636260c9a to your computer and use it in GitHub Desktop.

Install:

curl https://gist.githubusercontent.com/neilellis/41b1509bdf1636260c9a/raw/509e253297d031733474fd8dc373c93ca5c6b33e/dkr > ~/.dkr
echo ". ~/.dkr" >> ~/.bash_profile
dkr() {
case "$1" in
comp|co|compose) shift; docker-compose $@ ;;
mac|mc|machine) shift; docker-machine $@ ;;
swm|swarm) shift; docker-swarm $@ ;;
cup) shift; docker-compose up $@ ;;
refresh) docker-compose kill; docker-compose rm; docker-compose build && docker-compose up ;;
it) shift; docker run -t -i -P $@ ;;
open) shift; open "http://$(docker-machine ip default):$1" ;;
clean) docker rmi $(docker images -q); docker rm $(docker ps -q -a) ;;
*) docker $@ ;;
esac
}
@neilellis
Copy link
Author

@tiffanyfay
Copy link

Shorthand is a great idea! I have been using aliases.
I'd favor dkr over doc since doc makes me think documentation (seems you favored it too).

For compose, machine, and swarm I think it would be more consistent to have at least one of the options have the same number of characters for the shorthand (e.g. if comp was cmp since you have mac and swm). Things like cup seem better for the user to just add vs be a part of Docker since it'd just be the same as dkr co up. I think you can do docker run -tiP if you want to save spaces and hyphens regarding your dkr it.

Regarding Solomon's comments about combining/customizable:
Could potentially add compose, swarm, and machine into the existing docker CLI. Then everything would just start with docker and a user could more easily see what options there are. However that would make it cluttered and potentially misplaced. A combined CLI of some sorts would be nice though (at least with compose, machine, and swarm). If not dkr, could maybe be dkro dkrorch?dockero? dockerorch? (docker orchestration)...trying to think of something that is similar, but not a ton more characters. Coming stock with those, but then having a way to add your own shortcuts/run commands as part of Docker vs. bashrc/profile would be a neat feature.

If docker-compose (or any of them) could take multiple parameters in a way to get it to do your refresh, that would be cool vs. needing to type that every time.

Could maybe have some dockeri (docker interactive) mode and if you run that then you can run all your docker commands without prefacing them with docker and then exit that if you want to do things with machine,compose, etc.

For docker-machine adding a set command to docker-machine env <name> like the unset vs copy-pasting the eval would be nice...unless I am just using --shell wrong.

Another cool thing would be if you get enough of the command that it's differentiable that it uses that command. (e.g. docker a does docker active since nothing else starts with an a and docker stat does docker status, but docker st fails since there are multiple options with st).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment