{"id":16672,"date":"2017-03-27T16:15:59","date_gmt":"2017-03-27T13:15:59","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=16672"},"modified":"2017-12-19T12:06:28","modified_gmt":"2017-12-19T10:06:28","slug":"docker-node-js-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/","title":{"rendered":"Docker Node.js Example"},"content":{"rendered":"<p>Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it&#8217;s a technology that it&#8217;s widely used, so, sooner or later, a web developer (and sysadmin) will have to face it, meaning this that everyone should have, at least, a basic knowledge about it.<\/p>\n<p>This example will show how to easily set up a Node environment, within a Docker container.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;OCKUMTbC259tpbxG&#8217;]<br \/>\n&nbsp;<br \/>\nFor this example, Linux Mint 18 and Docker version 1.12.6 have been used.<\/p>\n<div class=\"tip\"><strong>Tip<\/strong><br \/>\nYou may Docker installation\u00a0and jump directly to the <a href=\"#section_2\"><strong>beginning of the example<\/strong><\/a> below.<\/div>\n<h2>1. Installation<\/h2>\n<p><strong>Note<\/strong>: Docker requires a 64-bit system with a kernel version equal or higher to 3.10.<\/p>\n<p>We can install Docker simply via <code>apt-get<\/code>, without the need of adding any repository, just installing the <code>docker.io<\/code> package:<\/p>\n<pre class=\"brush:bash\">sudo apt-get update\r\nsudo apt-get install docker.io\r\n<\/pre>\n<p>For more details, you can follow the <a href=\"https:\/\/www.webcodegeeks.com\/devops\/install-docker-ubuntu-tutorial\/\">Install Docker on Ubuntu Tutorial<\/a>.<\/p>\n<h2 id=\"section_2\">2. Using the official image<\/h2>\n<p>Node developers host their Docker images officially in the <a href=\"https:\/\/hub.docker.com\/r\/_\/node\/\">Docker Hub<\/a>. There are images available under many tags, but for this simple case, it&#8217;s more than enough to use the latest image:<\/p>\n<pre class=\"brush:bash\">docker pull node<\/pre>\n<p>Now, let&#8217;s create an extremely simple JavaScript script:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>hello_world.js<\/em><\/span><\/p>\n<pre class=\"brush:javascript\">var args = process.argv.slice(2);\r\n\r\nif (args.length === 0) {\r\n    console.error('Please, pass your name as an argument to the script.');\r\n} else {\r\n    console.log('Hello, ' + args.join(' '));\r\n}<\/pre>\n<p>Just a polite script that greets the specified name.<\/p>\n<p>The simplest way of executing a Node script within the container, is to do it on its creation, for example:<\/p>\n<pre class=\"brush:bash\">docker run --rm \\\r\n           --name=node_hello_world \\\r\n           -v $(pwd):\/usr\/src\/app \\\r\n           node:latest \\\r\n           node \/usr\/src\/app\/hello_world.js Julen<\/pre>\n<p>This may seem complicated, but it&#8217;s actually very easy. Let&#8217;s understand it:<\/p>\n<ul>\n<li>The\u00a0<code>rm<\/code> option is just for deleting the container when it exists.<\/li>\n<li>Then, we set a name to the container. Nothing really special.<\/li>\n<li>With <code>-v<\/code> option, we mount a volume from the host to the container. In this case, we mount the current working directory (pwd) of the host, where the <code>hello_world.js<\/code> is placed; to the <code>\/usr\/src\/app<\/code> directory, which actually could be any directory in the container.<\/li>\n<li>After that we specifiy the image name. We have done it specifying the tag name, not to mix up with the <code>node<\/code> command later.<\/li>\n<li>Finally, we just execute <code>node<\/code>, specifying the path of our script, and passing an argument to it.<\/li>\n<\/ul>\n<p>The output of the above command would be:<\/p>\n<blockquote><p>Hello, Julen<\/p><\/blockquote>\n<p>As expected.<\/p>\n<h2>3. Creating a Dockerfile from the scratch<\/h2>\n<p>In the previous section we have seen how to make a Node container work, but not in an actually very useful way, since we had to mount a volume just for executing the script. Now, let&#8217;s build a Dockerfile for a proper management of the example above.<\/p>\n<p>It can be really simple:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Dockerfile<\/em><\/span><\/p>\n<pre class=\"brush:bash\">FROM node:4\r\nMAINTAINER Julen Pardo &lt;julen.pardo@outlook.es&gt;\r\n\r\nCOPY hello_world.js \/usr\/src\/app\/\r\n\r\nENTRYPOINT [\"node\", \"\/usr\/src\/app\/hello_world.js\", \"Julen\"]...<\/pre>\n<p>So now our script will be inside the container.<\/p>\n<p>We can build the image executing:<\/p>\n<pre class=\"brush:bash\">docker build -t mynode1 . # Path to Dockerfile.<\/pre>\n<p>And, when running it:<\/p>\n<pre class=\"brush:bash\">docker run --rm mynode1<\/pre>\n<p>We will receive the same result as in the previous section.<\/p>\n<h2>4. Installing the PM2 process manager<\/h2>\n<p>We have just seen how to execute JavaScript scripts with Node, but, usually, when developing Node applications, is for serving them. For this purpose, the most complete process manager is, probably, PM2.<\/p>\n<p>First, let&#8217;s create a script that will create a server:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>server.js<\/em><\/span><\/p>\n<pre class=\"brush:javascript\">var DEFAULT_PORT = 3000;\r\n\r\nvar http = require('http');\r\nvar url = require('url');\r\n\r\nvar server = http.createServer(function (request, response) {\r\n   response.writeHead(\r\n       200,\r\n       {\r\n           \"Content-Type\": \"text\/plain\"\r\n       }\r\n   );\r\n\r\n   var query = url.parse(request.url, as_object = true).query;\r\n   response.end('GET parameters: ' + JSON.stringify(query));\r\n});\r\n\r\nserver.listen(DEFAULT_PORT);\r\n\r\nconsole.log('Server listening on port: ' + DEFAULT_PORT);<\/pre>\n<p>This app just creates a server listening the port 3000, and, when accessing it, displays the GET parameters.<\/p>\n<p>The difference with the previous Dockerfile is that we have to install the NPM <code>pm2<\/code> and <code>url<\/code> packages:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Dockerfile<\/em><\/span><\/p>\n<pre class=\"brush:bash\">FROM node:4\r\nMAINTAINER Julen Pardo &lt;julen.pardo@outlook.es&gt;\r\n\r\nENV DEBIAN_FRONTEND=noninteractive\r\n\r\nRUN npm install -g pm2\r\nRUN npm install -g url\r\n\r\nCOPY server.js \/usr\/src\/app\/\r\nRUN chown node:node \/usr\/src\/app\/server.js\r\nRUN chmod a+rx \/usr\/src\/app\/server.js\r\n\r\nCOPY scripts\/docker-entrypoint.sh \/\r\nRUN chmod 777 \/docker-entrypoint.sh\r\n\r\nENTRYPOINT \/docker-entrypoint.sh<\/pre>\n<p>Note that we have defined the entry point in a separate file:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>docker-entrypoint.sh<\/em><\/span><\/p>\n<pre class=\"brush:bash\">#!\/bin\/bash\r\n\r\nsu - node -c \"pm2 start \/usr\/src\/app\/server.js\"\r\n\r\nsleep infinity<\/pre>\n<p>It&#8217;s always important not to start the service with the root user, as made in the script. Then, we just keep alive the container with the last command.<\/p>\n<p>Now, we can just build our image:<\/p>\n<pre class=\"brush:bash\">docker build -t mynode2 . # Path to the Dockerfile.\r\n<\/pre>\n<p>And create the container, binding the port 3000 to some port in the host. If we\u00a0don&#8217;t have a web server running in the host, we can bind it to the port 80:<\/p>\n<pre class=\"brush:bash\">docker run -d --name=node_server -p 80:3000 mynode2\r\n<\/pre>\n<p>That&#8217;s it! We can now access our Node application, following <code>http:\/\/localhost<\/code>, and, of course, being able to pass parameters via GET. So, for example, opening the\u00a0<code>http:\/\/localhost?key1=value1&amp;key2=value2<\/code> URL, would show in the browser:<\/p>\n<blockquote><p>GET parameters: {&#8220;key1&#8243;:&#8221;value1&#8243;,&#8221;key2&#8243;:&#8221;value2&#8221;}<\/p><\/blockquote>\n<h3>4.1 Troubleshooting<\/h3>\n<p>It shouldn&#8217;t happen following the steps described above, but it&#8217;s always good to know how to act when some error happens.<\/p>\n<p>In this situation, there are two steps we should follow:<\/p>\n<ul>\n<li>Don&#8217;t run the container in dettached mode, for seeing the output of PM2.<\/li>\n<li>Check the PM2 log.<\/li>\n<\/ul>\n<p>For the first one, we just have to run the container in interactive mode, with the <code>-it<\/code> option, and without the <code>-d<\/code> one, like the following:<\/p>\n<pre class=\"brush:bash;highlight:[22]\">docker run -it --name=node_server -p 80:3000 mynode2\r\n<\/pre>\n<p>This way, the output of PM2 will be shown, like in the following image (for which there&#8217;s no error):<\/p>\n<figure style=\"width: 700px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/pm2_output.jpg\" alt=\"\" width=\"700\" height=\"735\" \/><figcaption class=\"wp-caption-text\">1. PM2 output.<\/figcaption><\/figure>\n<p>For the second one, we have to get the shell of the container, and check the PM2 log, in the following way:<\/p>\n<pre class=\"brush:bash;highlight:[22]\">docker exec -it node_server \/bin\/bash # Get shell of the container.\r\n# Inside the container\r\nsu - node\r\npm2 log<\/pre>\n<p>Note that we execute the PM2 command as the user that started the PM2 process, since it belongs to it; the users won&#8217;t see the PM2 processes of other users.<\/p>\n<p>That command will simply tail the log file. If the tail of the log file is not enough, we can check the full log file, which is placed in the <code>.pm2\/logs<\/code> directory in the home directory of the user that owns the PM2 process. So, in this case, the logs are located in <code>\/home\/node\/.pm2\/logs<\/code><\/p>\n<h2>5. Running Node app behind\u00a0Nginx<\/h2>\n<p>For some scenarios, we may want to run our Node application behind a real web server. Let&#8217;s see how to do it easily with a reverse proxy with Nginx as web server.<\/p>\n<p>The Nginx virtual host configuration should be something similar to the following one:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>node_app.conf<\/em><\/span><\/p>\n<pre class=\"brush:bash;highlight:[22]\">server {\r\n    listen [::]:80;\r\n    listen 80;\r\n\r\n    server_name localhost;\r\n\r\n    access_log \/var\/log\/nginx\/node_app.log;\r\n    error_log \/var\/log\/nginx\/node_app.log;\r\n\r\n     location \/ {\r\n         proxy_read_timeout 300;\r\n         proxy_connect_timeout 300;\r\n         proxy_redirect on;\r\n\r\n         proxy_http_version 1.1;\r\n\r\n         proxy_set_header Host $http_host;\r\n         proxy_set_header X-Real-IP $remote_addr;\r\n         proxy_set_header X-Forwarded-Ssl on;\r\n         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n         proxy_set_header X-Forwarded-Proto $scheme;\r\n         proxy_pass http:\/\/127.0.0.1:3000;\r\n     }\r\n}<\/pre>\n<p>The most important configuration here is the highlighted one, when we set the address and port for the reverse proxy.<\/p>\n<p>Then, we just have to edit the Dockerfile, for installing Nginx and adding the config file:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Dockerfile<\/em><\/span><\/p>\n<pre class=\"brush:bash;highlight:[22]\"># ...\r\n\r\nRUN apt-get update\r\nRUN apt-get install -y nginx\r\n\r\nCOPY files\/node_app.conf \/etc\/nginx\/sites-enabled\/\r\n\r\n# ...<\/pre>\n<p>And, restarting Nginx in the entry point script:<\/p>\n<p><em><span style=\"text-decoration: underline;\">docker-entrypoint.sh<\/span><\/em><\/p>\n<pre class=\"brush:bash;highlight:[22]\"># ...\r\n\r\nservice nginx restart\r\n\r\n# ...<\/pre>\n<p>Now we can build the image as always:<\/p>\n<pre class=\"brush:bash;highlight:[22]\">docker build -t mynode3 . # Path to Dockerfile.<\/pre>\n<p>And instantiate the container, but, now, binding container&#8217;s port 80 instead of 3000, because our Node process is now behind Nginx, which is running in the port 80.<\/p>\n<pre class=\"brush:bash;highlight:[22]\">docker run -d --name=node_server -p 80:80 mynode3<\/pre>\n<p>Now, we should be able to access the application in the same way as before.<\/p>\n<h2>6. Summary<\/h2>\n<p>With this example we have seen how to set up a Node environment, from the most simple case, just pulling the official Node image, for just executing scripts from the command line; to serving Node applications with PM2. We have also seen how to serve these applications behind Nginx, a usual practice that sooner or later we will have to face.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it&#8217;s a technology that it&#8217;s widely used, so, sooner or later, a web developer (and sysadmin) will have to face it, meaning this that everyone should have, at least, a basic knowledge about it. This example will show how to easily set &hellip;<\/p>\n","protected":false},"author":160,"featured_media":10356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[217],"class_list":["post-16672","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-docker"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Docker Node.js Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it&#039;s a technology that it&#039;s widely used, so, sooner\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker Node.js Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it&#039;s a technology that it&#039;s widely used, so, sooner\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-27T13:15:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-19T10:06:28+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Toni\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Toni\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/\"},\"author\":{\"name\":\"Toni\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/54a7be647b0b871cff41cbf3d2a95966\"},\"headline\":\"Docker Node.js Example\",\"datePublished\":\"2017-03-27T13:15:59+00:00\",\"dateModified\":\"2017-12-19T10:06:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/\"},\"wordCount\":1071,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"keywords\":[\"Docker\"],\"articleSection\":[\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/\",\"name\":\"Docker Node.js Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"datePublished\":\"2017-03-27T13:15:59+00:00\",\"dateModified\":\"2017-12-19T10:06:28+00:00\",\"description\":\"Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it's a technology that it's widely used, so, sooner\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DevOps\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/devops\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Docker Node.js Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/54a7be647b0b871cff41cbf3d2a95966\",\"name\":\"Toni\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g\",\"caption\":\"Toni\"},\"url\":\"https:\/\/www.webcodegeeks.com\/author\/julen-pardo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Docker Node.js Example - Web Code Geeks - 2026","description":"Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it's a technology that it's widely used, so, sooner","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/","og_locale":"en_US","og_type":"article","og_title":"Docker Node.js Example - Web Code Geeks - 2026","og_description":"Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it's a technology that it's widely used, so, sooner","og_url":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-03-27T13:15:59+00:00","article_modified_time":"2017-12-19T10:06:28+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","type":"image\/jpeg"}],"author":"Toni","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Toni","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/"},"author":{"name":"Toni","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/54a7be647b0b871cff41cbf3d2a95966"},"headline":"Docker Node.js Example","datePublished":"2017-03-27T13:15:59+00:00","dateModified":"2017-12-19T10:06:28+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/"},"wordCount":1071,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","keywords":["Docker"],"articleSection":["DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/","url":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/","name":"Docker Node.js Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","datePublished":"2017-03-27T13:15:59+00:00","dateModified":"2017-12-19T10:06:28+00:00","description":"Despite the controversy and different opinions that\u00a0Node.js generates among web developers, after all, it's a technology that it's widely used, so, sooner","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/devops\/docker-node-js-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"DevOps","item":"https:\/\/www.webcodegeeks.com\/category\/devops\/"},{"@type":"ListItem","position":3,"name":"Docker Node.js Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/54a7be647b0b871cff41cbf3d2a95966","name":"Toni","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g","caption":"Toni"},"url":"https:\/\/www.webcodegeeks.com\/author\/julen-pardo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/16672","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/160"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=16672"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/16672\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/10356"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=16672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=16672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=16672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}