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.

dockerit ubuntu

CLI tooling

Quite often people want an easy way to run CLI tooling scripts in a container rather than needing to install them locally. An example would be composer for the PHP world, or npm for the Javascript world.

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)

Further options

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.

Flags: --entry Use the default entrypoint. If entry=0 you must provide one (default true) -e, --env stringArray Set environment variables -h, --help help for dockerit --home Mount the home directory of the user --magic Magically use magic settings based on the image being used --me User override for the command, runs as current user --port string Port mapping <host>:<container> eg. 8080:80 --pull Pull the docker image even if present --pwd Mount the PWD into the container (and set as working directory /pwd) --selfupdate Update this command to the latest release from GitHub --user string User override for the command -v, --verbose verbose output --version version information
Code language: JavaScript (javascript)