Skip to content

Instantly share code, notes, and snippets.

@ryan0x44
Created July 9, 2018 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan0x44/cb7c612e233e7a470b41deb61bcc5bd9 to your computer and use it in GitHub Desktop.
Save ryan0x44/cb7c612e233e7a470b41deb61bcc5bd9 to your computer and use it in GitHub Desktop.
Node/NPM/Yarn via Docker Run

To start a bash prompt with only Docker installed on your host OS, run the following command:

docker run --rm -v $PWD:/src -w /src -u node -it node /bin/bash

Here's what each parameter does:

  • --rm removes the container once you exit
  • -v $PWD:/src will mount your current host working directory into /src inside the container
  • -w /src will set the working directory of the container to /src
  • -u node will set the user/UID to node
  • -it will enable interactive mode (keep STDIN open) and allocate a pseudo-TTY
  • node is the latest node docker image
  • /bin/bash is the command that will be run

From there, you'll be able to run commands like node, npm and yarn without having to install them locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment