dockerit v0.0.5 (Easier than docker run)
dockerit is a small CLI tool that I have been working on during the start of 2021. It’s intended to make running one off commands and CLI tooling easier in docker. Rather than having to write a long string of parameters for
docker run, instead you can just use dockerit. This applies to both CLI usage, but also via bash aliases.
You can download a build binary of dockerit from the Github releases page.
One off image testing
Quite often you might want to dive into a container to check some file system layout, check the contents of a file, or try running some commands.
docker run --rm -it ubuntu
dockerit automatically assumes that you are running one off commands and will want to remove the container afterward. Also assuming that you want an interactive session.
If these tools are meant to interact with your code on disk, you’ll likely need volume mounts and user options. If they make use of a cache between requests, you might need to mount that too.
docker run --rm -it --volume $(pwd)/:/pwd --volume ~/:~/ --user $(id -u):$(id -g) composer update
A comparable dockerit command would be much shorter
dockerit --pwd --home --me composer update
Some images even have a set of “magic” defaults that can be used
dockerit --magic composer update
dockerit simplifies commands and can lead to much easier to read bash aliases, rather than repeating volume mounts etc over and over again.
# composer alias composer1='dockerit --magic composer:1 -- composer' alias composer2='dockerit --magic composer:2 -- composer' alias composer='composer2' # npm alias npm='dockerit --magic node -- npm'Code language: PHP (php)
Other options exist for common use cases and more can easily be added. This is a subset of the regular
docker run options, with some magic shortcuts sprinkled in.