New to docker. I wanted to create a simple Node.js
app using docker
on my Ubuntu OS. But all the tutorials/YouTube Videos are first installing Node on host machine, then run and test the app, and then dockerizing the app. Means all the tutorials are simply teaching "How to dockerize an existing app".
If anyone can provide a little guidance on this then it would be really helpful.
2
Answers
Follow this
You can create package*.json ./ files manually, if you don’t want to install node/npm on your local machine.
First create a directory for your source code and create something like the starter app from here in app.js. You have to make one change though:
hostname
has to be 0.0.0.0 rather than 127.0.0.1.Then run an interactive node container using this command
This container has your host directory mapped to
/app
, so if you doyou should see your app.js file.
Now you can run it using
If you then switch back to the host, open a browser and go to
http://localhost:3000/
you should get a ‘Hello world’ response.