Skip to content

Instantly share code, notes, and snippets.

@Eruant
Last active November 14, 2016 12:28
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 Eruant/11e37f3605ab5fa8c5dc99f261133d5b to your computer and use it in GitHub Desktop.
Save Eruant/11e37f3605ab5fa8c5dc99f261133d5b to your computer and use it in GitHub Desktop.
Run node with docker
# `node` run node 6
# `node 3000:8080` run node 6 exposing port 8080 to docker:3000
function node {
if [[ -n "$1" ]]; then
docker run -i \
-v $(pwd):/app \
-v $HOME/.ssh:/root/.ssh \
-w='/app' \
-p $1 \
-t node:6 bash
else
docker run -i \
-v $(pwd):/app \
-v $HOME/.ssh:/root/.ssh \
-w='/app' \
-t node:6 bash
fi
}
# `node-latest` run node 6
# `node-latest 3000:8080` run node 6 exposing port 8080 to docker:3000
function node-latest {
if [[ -n "$1" ]]; then
docker run -i \
-v $(pwd):/app \
-v $HOME/.ssh:/root/.ssh \
-w='/app' \
-p $1 \
-t node:latest bash
else
docker run -i \
-v $(pwd):/app \
-v $HOME/.ssh:/root/.ssh \
-w='/app' \
-t node:latest bash
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment