Skip to content

Instantly share code, notes, and snippets.

@n0bodysec
Last active December 14, 2022 19:37
Show Gist options
  • Save n0bodysec/07bde7e8946a2d933d1dfffa153d6b29 to your computer and use it in GitHub Desktop.
Save n0bodysec/07bde7e8946a2d933d1dfffa153d6b29 to your computer and use it in GitHub Desktop.
Node.js container alias
# without global modules
alias dn='docker run --rm -it -v $PWD:/app -w /app node'
# with global modules
docker run --rm -it -v $PWD:/app -v $HOME/.npm-global:/.npm-global -w /app -e NPM_CONFIG_PREFIX=/.npm-global -e PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/.npm-global/bin" node
# without global modules
function dn { docker run --rm -it -v $pwd\:/app -w /app node $args }
# with global modules
function dn { docker run --rm -it -v $PWD\:/app -v $HOME\.npm-global:/.npm-global -w /app -e NPM_CONFIG_PREFIX=/.npm-global -e PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/.npm-global/bin" node $args }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment