Dock Life: Using Docker for All The Things!

Interesting take by the folks at nystudio107: instead of installing things such as node locally, why not run it in a container with an alias linked to it?

Instead of installing all of the tools & pack­ages you’re used to using, we use Dock­er images that some­one else has cre­at­ed that con­tain these tools & packages.

In order to seam­less­ly pro­vide access to var­i­ous tools run via Dock­er, we’re going to use shell aliases.

For example, to have various node versions available, set up these aliases:

alias node='docker run --rm -it -v "$PWD":/app -w /app node:18-alpine '
alias node16='docker run --rm -it -v "$PWD":/app -w /app node:16-alpine '
alias node14='docker run --rm -it -v "$PWD":/app -w /app node:14-alpine '

With that set up, you can run node script.js as you’d normally do.

Same can be done for other node versions, npm, composer, deno, …

Dock Life: Using Docker for All The Things! →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Join the Conversation

1 Comment

  1. This is what I’ve been doing for a while, specifically with Node since I hate having it installed in my system but sometimes need to run some commands with it.

Leave a comment

Your email address will not be published. Required fields are marked *

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