{"id":21168918,"url":"https://github.com/suwigyarathore/docker-node","last_synced_at":"2026-04-13T23:02:01.886Z","repository":{"id":116085822,"uuid":"90499200","full_name":"suwigyarathore/docker-node","owner":"suwigyarathore","description":"Node.js app dockerized using latest node.js image","archived":false,"fork":false,"pushed_at":"2017-05-07T00:49:52.000Z","size":321,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T10:31:29.827Z","etag":null,"topics":["docker","express","node","node-docker","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suwigyarathore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-07T00:28:32.000Z","updated_at":"2017-05-07T00:59:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"c0ad7b41-39ee-4eb2-a659-32cdab2f4941","html_url":"https://github.com/suwigyarathore/docker-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suwigyarathore%2Fdocker-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suwigyarathore%2Fdocker-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suwigyarathore%2Fdocker-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suwigyarathore%2Fdocker-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suwigyarathore","download_url":"https://codeload.github.com/suwigyarathore/docker-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243615631,"owners_count":20319733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","express","node","node-docker","nodejs"],"created_at":"2024-11-20T15:19:08.512Z","updated_at":"2026-04-13T23:01:56.859Z","avatar_url":"https://github.com/suwigyarathore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node-Express App on Docker\n\nSample NODE.js application deployed in docker in minimalistic manner\n\n## Getting Started\n\nWhy should I dockerize my application\n\nYou might've heard about the whole Docker thing, but that still doesn't answer the question: \"why bother?\" Well, that's why:\n\nYou can launch a fully capable development environment on any computer supporting Docker; you don't have to install libraries, dependencies, download packages, mess with config files etc.\nThe working environment of the application remains consistent across the whole workflow. This means the app runs exactly the same for developer, tester, and client, be it on development, staging or production server.\nIn short, Docker is the counter-measure for the age-old response in the software development: \"Strange, it works for me!\"\n\n### Prerequisites\n\nInstall Node.js\n\nIf you've never worked with Node.js before, kick off with installing the npm manager: nodejs.org/en/download/package-manager\n\nInstall NPM and Express Framework\n\n```\n$ mkdir helloworld\n$ cd helloworld\n$ npm init\n```\n\n### Installing\n\n```\n$ npm install express --save\n```\n\n*The file should look like this now:*\n```\n{\n  \"name\": \"helloworld\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" \u0026\u0026 exit 1\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"express\": \"^4.15.2\"\n  }\n}\n```\n\n*Details of Hello World*\n\nWith everything installed, we can create an index.js file with a simple HTTP server that will serve our Hello World website:\n\n```\n//Load express module with `require` directive\nvar express = require('express')\nvar app = express()\n\n//Define request response in root URL (/)\napp.get('/', function (req, res) {\n  res.send('Hello World!')\n})\n\n//Launch listening server on port 8081\napp.listen(8081, function () {\n  console.log('app listening on port 8081!')\n})\n```\n*The application is ready to launch:*\n\n```\n$ node index.js\n```\n\n### Write Dockerfile\n\n1. Line 1: Use another Docker image for the template of my image. We shall use the official Node.js image with Node v7.\n2. Line 2: Set working dir in the container to /app. We shall use this directory to store files, run npm, and launch our application:\n3. Line 3-5: Copy application to /app directory and install dependencies. If you add the package.json first and run npm install later, Docker won't have to install the dependencies again if you change the package.json file. This results from the way the Docker image is being built (layers and cache), and this is what we should do:\n\n```\nFROM node:7\nWORKDIR /app\nCOPY package.json /app\nRUN npm install\nCOPY . /app\nCMD node index.js\nEXPOSE 8081\n```\n\n### Build Docker image\n\nWith the instructions ready all that remains is to run the docker build command, set the name of our image with -t parameter, and choose the directory with the Dockerfile:\n\n```\n$ docker build -t hello-world .\n```\n\n### Run Docker container\n\nThe application has been baked into the image. Dinner time! Execute the following string to launch the container and publish it on the host with the same port 8081:\n\n```\ndocker run -p 8081:8081 hello-world\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuwigyarathore%2Fdocker-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuwigyarathore%2Fdocker-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuwigyarathore%2Fdocker-node/lists"}