Skip to content

Instantly share code, notes, and snippets.

@romuloctba
Created November 26, 2018 00:29
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 romuloctba/5f83b60b96a5b0a6c559b076eee8b240 to your computer and use it in GitHub Desktop.
Save romuloctba/5f83b60b96a5b0a6c559b076eee8b240 to your computer and use it in GitHub Desktop.
Development Enviroment for NodeJS via Docker

docker run --rm -it -w="/usr/src/app" -v $PWD/application:/usr/src/app:z --user $(id -u):$(id -g) node bash

Add ports as needed, example:

docker run --rm -it -w="/usr/src/app" -p 8080:8080 -p 3000:3000 -v $PWD/application:/usr/src/app:z --user $(id -u):$(id -g) node bash

Example: Developing Angular Apps with Docker

docker run --rm -it -w="/usr/src/app" -p 4200:4200 -v $PWD/application:/usr/src/app:z --user $(id -u):$(id -g) node bash then create a new project inside the docker terminal npx @angular/cli init

To serve your app, use --host=0.0.0.0. A good way of doing that is updating the package.json scrips sections, such as:

"scripts": {
    "ng": "ng",
    "start": "ng serve --host 0.0.0.0",

then, inside the docker container, run npm start

Open the browser at localhost:4200 and you should be good to go.

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