Home » DevOps » dockerw – A simple Docker command wrapper for the rest of us

About Jens Deters

Jens Deters is a Senior Software Developer working in the domain of Aviation Authorities. His main objectives are RIA and Desktop Applications also he loves to play with IoT related stuff.

dockerw – A simple Docker command wrapper for the rest of us

I am regularly working on Docker images and have to play with different settings. Thus I periodically find myself in the “build, run, clean-up, change something, re-build, run, …” rat race.

dockerw is a little tool for working with Docker images and containers. And it aims to help you (and me ;-)) to build and (locally) run Docker images while it hides all the command line pain.

Note: dockerw targets only ‘latest’ tagged images (does not impact /touch implicit tagged images)!



./dockerw [ build | run | stop | clean | status | env | help ]


buildbuilds the Docker image
runruns a Docker container in foreground based on the image
stopstops all running container based on the image and removes them
cleanstop and then removes ALL (latest) images/artifacts<
statusshows the status if the Docker image
envlist current environment variables
helpdisplay help










  1. Clone dockerw from GitHub.
  2. Create a dockerw directory ahead your Docker working dir and copy the dockerw.sh script to that location.
  3. Copy/create a script named “dockerw"located into the working directory of a your Docker image.

If you are using default values only: the dockerw script just calls the dockerw.sh:

# call dockerw.sh, passing arguments and using env variables
. ../dockerw/dockerw.sh

You can overule the default environment like this:

# env
DOCKER_RUN_ARGS="-ti -p 1883:1883 -p 8883:8883"

# call dockerw.sh, passing arguments and using env variables
. ../dockerw/dockerw.sh



The CONTAINER_NAME is the parent working directory base name.
The default base name (BASE_NAME_DEFAULT) and default docker run arguments (DOCKER_RUN_ARGS_DEFAULT) can be changed in dockerw/dockerw.sh.
The image name (IMAGE_NAME) is build like this: BASE_NAME_DEFAULT/CONTAINER_NAME (e.g. jerady/ubuntu).

Environment Variables

the name of the docker image”${`BASE_NAME`}/${`CONTAINER_NAME`}”jerady/mosquitto

BASE_NAMEthe base name of the Docker containerjeradyjerady
CONTAINER_NAMEthe name of the Docker container$(`basename ‘pwd’`)mosquitto
IMAGE_NAMEthe name of the Docker image${BASE_NAME}/${CONTAINER_NAME}jerady/mosquitto
DOCKER_RUN_ARGSthe arguments to run the container-ti-ti
DOCKER_RUNthe docker run command to be called by ./dockerw rundocker run ${DOCKER_RUN_ARGS} --name ${CONTAINER_NAME} ${IMAGE_NAME}docker run -ti --name mosquitto jerady/mosquitto

I added two example Docker images/projects to show how the custom dockerw script can be implemented, e.g. this simple script for mosquitto:


# env variables
DOCKER_RUN_ARGS="-ti -p 1883:1883 -p 8883:8883"

. ../dockerw/dockerw.sh

leads to these implicit values:



dockerw project on GitHub

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments