Mostrando entradas de agosto, 2017

Creating a Docker container for a NodeJs application

This is a simple Docker tutorial for creating your first NodeJs container, above is the vid and below you will find the steps followed.

StepsPre-reqsHave node.js installedAnd docker installed Create an incredibly simple node appCreate your first container Build and Run your new container Create your simple node appnpm initcreate the index.js Create a dockerfileInclude container with node preinstalled: FROM nodeCreate default/working directory: WORKDIR /usr/src/appCopy package.json to workdir and install dependencies (not really needed for this app but you might need it😊): COPY package.json .RUN npm install Copy the rest of the app (just the index.js file in this case)COPY . .Add a command to run when this container is startedCMD ["node", "index.js"] Build & RunBuild the container:docker build -t my-node-app . Run the containerdocker run my-node-app
ResourcesDockerizing a Node.js web app