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
cmp
since you havemac
andswm
). Things likecup
seem 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 -tiP
if 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
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 notdkr
, could maybe bedkro
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 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 yourdocker
commands without prefacing them withdocker
and then exit that if you want to do things with machine,compose, etc.For
docker-machine
adding a set command todocker-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
doesdocker active
since nothing else starts with an a anddocker stat
doesdocker status
, butdocker st
fails since there are multiple options with st).