Docker of Things

We all want to experiment on the latest thing, technology or OSs. Often times we move to another flavor of operating system because we get bored or just want a new shiny view.

It’s very tiring though. Every time you install new dependencies on your system, your OS gets bloated, suffers performance issues, and sometimes get broken. So you format it? Then you install them back again and spend the next few hours setting up your workflow.

We want our tools to follow us. So that on any environment - development, staging or production - we can be productive in the next 30 minutes without much fuss in installing our favorite toys.

We would want to dispatch our tools - upgrade or replace - on demand.

How would we do that?

Introducing Docker

Let’s say you want to build a new React app. Your usual route would be is to install a specific NodeJS version for your project to your local environment, easy enough. But what if you don’t want to make a mess with your system because you like being clean? ;-)

Anyway, let’s see the usual route first:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

npx create-react-app webapp --template typescript

cd webapp && yarn start

In most cases, this setup is enough. That is, you have a simple project requirements, not needing to work or switch between different version of the compiler.

Anyway, here’s the Docker route if you have advance use case:

docker pull node:12.16.3

docker run -it --rm -v $PWD/webapp:/webapp node:12.16.3 \ 
    npx create-react-app webapp --template typescript

The above code will pull up a Node image with the specified version.

The second command will create a React app, install the dependencies inside the container but since we are binding to local directory we will see the changes in our host directory.

The -v flag means we want to bind our current local directory to a container directory /webapp.

To start our newly created app:

docker run -it --rm -v $PWD/webapp:/webapp -w="/webapp" node:12.16.3 yarn start

The -w flag means working directory. Since we want our command yarn start to run inside that container directory.


Although it’s a lot of commands to follow we can mitigate that by abstracting it away i.e. creating alias or another script to wrap the command.

Why would I want to do this?
  • You want to use Technology v12 but you still have projects relying on Technology v10.
  • You move to different environments and operating systems i.e. MacOS to Linux to Windows and or development, staging to production
  • You have more than one workflow
  • You want your tools to be at your disposal on demand, replaceable and upgradable.
  • Because you want a clean environment ;-)

Join my newsletter and get monthly articles on productivity, habits, and decision making in your inbox.