title: Error: getaddrinfo ENOTFOUND redis-server
body: <p>Dockerfile</p>
  <pre class="lang-sh prettyprint-override"><code>FROM node:alpine    
  WORKDIR /usr/app
  COPY ./package.json ./
  RUN npm install 
  COPY ./ ./
  CMD [&quot;npm&quot;,&quot;start&quot;]
  </code></pre>
  <p>docker-compose.yml</p>
  <pre class="lang-yaml prettyprint-override"><code>version: '3'
  services:
    redis-server:
     image: 'redis'
     ports:
       - &quot;6379:6379&quot;
    node-app:
     build: .
     ports:
       - &quot;8081:8081&quot;
  </code></pre>
  <p>app.js</p>
  <pre class="lang-js prettyprint-override"><code>const express = require('express');
  const redis = require('redis');
  const app = express();
  const client = redis.createClient({ host:'redis-server', port: 6379 });
  client.set('visits', 0);
  app.get('/', (req, res) =&gt; { client.get('visits', (err, visits) =&gt; { res.send('Number of visits is ' + visits); client.set('visits', parseInt(visits) + 1); }); });
  app.listen(8081, () =&gt; { console.log('Listening on port 8081'); });
  </code></pre>
  <p>Error</p>
  <pre><code>Error: getaddrinfo ENOTFOUND redis-server
  </code></pre>
  <p>Docker Image creation and running continer steps</p>
  <pre><code>############################ 
  Image ID - f419c79d6ce7 
  Image Name - myapp
  
  Image ID - 739b59b96069 
  Image Name - redis 
  #############################
  
  docker run -d --net &quot;redis&quot; --name redis redis 
  docker run -d -p 8081:8081 myapp 
  ######### --------------error ----------------########
  Error: getaddrinfo ENOTFOUND redis-server
  </code></pre>