Testing Python Packages with Docker

Package management is hard. Sometimes in Python package development, your local (development) environment may behave a little differently than a deployment target. Below is a simple method I use to replicate a clean environment and test Python package installs and tests.

docker run -v `pwd`:`pwd` -w `pwd` python pip install .
docker run -v `pwd`:`pwd` -w `pwd` python python setup.py install
docker run -v `pwd`:`pwd` -w `pwd` python python setup.py test

First, we bind the current directory to our container (-v) and switch our working directory (-w). Second, we run our commands.

Nicholas Nadeau, Ph.D., P.Eng.
Nicholas Nadeau, Ph.D., P.Eng.

Nicholas Nadeau empowers teams through fractional CTO services to build next-generation technologies. Subscribe to my newsletter to keep up with the latest trends and explore my services to jumpstart your innovation.