DEV Community

Dylan Ballandras
Dylan Ballandras

Posted on • Originally published at on

Use Docker to quickly start projects

I just installed WSL2 on my computer with an pristine Ubuntu 20.04 installationand I didn’t want to install most of languages and software I would use for my projects.

Then, I forced myself to use docker run --rm as much as possible.

Here are a few example for some type of projects.

Installing and running Node/NPM based projects

Imagine running a Snowpack or Gatsby based project.

  • docker run --rm -it -v $PWD:/usr/src/app -w /usr/src/app node:12 yarn install
  • docker run --rm -it -p 8000:8000 -v $PWD:/usr/src/app -w /usr/src/app node:12 yarn start

Running a PHP project

You could even composer create, composer install or php -S -t public a Symfony project.

  • docker run --rm --interactive --tty --volume $PWD:/app composer create-project sylius/sylius-standard acme
  • docker run --rm --interactive --tty --volume $PWD:/app composer install
  • docker run -it --rm -p 8000:8000 -v "$PWD":/usr/src/myapp -w /usr/src/myapp php:7.4-cli php -S -t public

Keep track of your scripts

You can leverage a Makefile or Shell script to commit those scripts.

As an example, for my blog, I use the following configuration:

.DEFAULT\_GOAL := help

.SILENT: help

path := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE\_LIST)))))


    docker run --rm -it -v ${path}:/usr/src/app -w /usr/src/app node:12 yarn install


    docker run --rm -it -p 8000:8000 -v ${path}:/usr/src/app -w /usr/src/app node:12 yarn develop --host=

Enter fullscreen mode Exit fullscreen mode

Thank to that, I can try the next Node versions before pushing to production.

You can find how to easily do the same for any type of language by going to the is often a Run a single script part for the main Docker images.

Then, if you need to go further, using docker-compose seems to be interesting to create a “network” of container (eg. add a database, a mailcatcher, etc.).


Discussion (0)