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 | |
| } |
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
cmpsince you havemacandswm). Things likecupseem better for the user to just add vs be a part of Docker since it'd just be the same asdkr co up. I think you can dodocker run -tiPif you want to save spaces and hyphens regarding yourdkr 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
dockerand 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 notdkr, could maybe bedkrodkrorch?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 yourrefresh, 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 yourdockercommands without prefacing them withdockerand then exit that if you want to do things with machine,compose, etc.For
docker-machineadding a set command todocker-machine env <name>like the unset vs copy-pasting the eval would be nice...unless I am just using--shellwrong.Another cool thing would be if you get enough of the command that it's differentiable that it uses that command. (e.g.
docker adoesdocker activesince nothing else starts with an a anddocker statdoesdocker status, butdocker stfails since there are multiple options with st).