title: Dockerfile not working on backend with react
body: <p>I'm trying to run a react app with 2 node servers. One for the front end and one for the back-end connected with a mysql data-base.</p>
  <p>I'm trying to use docker for the container and I managed to get the database and the front-end server up. However,When the back-end server is fired it seems like it doesn't acknowledge the Dockerfile.</p>
  <pre><code>node_server | npm WARN exec The following package was not found and will be installed: nodemon
  node_server |   Usage: nodemon [nodemon options] [script.js[args]
  node_server | 
  node_server |   See &quot;nodemon --help&quot; for more.
  node_server | 
  node_server exited with code 0
  </code></pre>
  <p>Dockerfile - client:</p>
  <pre><code>FROM node:latest
  
  RUN mkdir -p /usr/src/app
  
  WORKDIR /usr/scr/app
  
  EXPOSE 3000
  
  COPY package.json .
  
  RUN npm install express body-parser nano nodemon cors
  
  COPY . .
  </code></pre>
  <p>Dockerfile - server</p>
  <pre><code>FROM node:latest
  
  RUN mkdir -p /usr/src/app
  
  WORKDIR /usr/src/app
  
  RUN npm init -y
  
  RUN npm install express body-parser nano nodemon cors
  
  EXPOSE 5000
  
  CMD [&quot;npx&quot;, &quot;nodemon&quot;, &quot;src/server.js&quot;]
  </code></pre>
  <p>docker-compose</p>
  <pre><code>version: '3'
  services:
  
    backend:
      build:
        context: ./server
        dockerfile: ./Dockerfile
      depends_on:
        - mysql
      container_name: node_server
      image:
        raff/node_server
      ports:
        - &quot;5000:5000&quot;
      volumes:
        - &quot;./server:/usr/src/app&quot;
   
  
    frontend:
      build:
        context: ./client
        dockerfile: ./Dockerfile
      container_name: node_client
      image:
        raff/node_client
      ports:
        - &quot;3000:3000&quot;
      volumes:
        - &quot;./client:/usr/src/app&quot;
      
  
    mysql:
      image: mysql:5.7.31
      container_name: db
      ports:
        - &quot;3306:3306&quot;
      environment:
        MYSQL_ROOT_PASSWORD: admin
        MYSQL_DATABASE: assignment
  </code></pre>
  <p>The server side is not done yet, but i don't believe it's causing this error.</p>
  <p>Server.js</p>
  <pre><code>&quot;use strict&quot;;
  
  const path = require(&quot;path&quot;);
  const express = require(&quot;express&quot;);
  const app = express();
  
  const bodyParser = require(&quot;body-parser&quot;);
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(express.json());
  
  const mysql = require(&quot;mysql&quot;);
  
  let con = mysql.createConnection({
    host: &quot;mysql&quot;,
    port: &quot;3306&quot;,
    user: &quot;root&quot;,
    password: &quot;admin&quot;,
  });   
   
  const PORT = 5000;
  const HOST = &quot;0.0.0.0&quot;;
  
  app.post(&quot;/posting&quot;, (req, res) =&gt; {
    var topic = req.body.param1;
    var data = req.body.param2;
  
    sql_insertion(topic, data);
  });
  
  // Helper
  const panic = (err) =&gt; console.error(err);
  
  // Connect to database
  con.connect((err) =&gt; {
    if (err) {
      panic(err);
    }
    console.log(&quot;Connected!&quot;);
    con.query(&quot;CREATE DATABASE IF NOT EXISTS assignment&quot;, (err, result) =&gt; {
      if (err) {
        panic(err);
      } else {
        console.log(&quot;Database created!&quot;);
      }
    });
  });
  
  //select database
  con.query(&quot;use assignment&quot;, (err, result) =&gt; {
    if (err) {
      panic(err);
    }
  });
  
  // Create Table
  let table =
    &quot;CREATE TABLE IF NOT EXISTS posts (ID int NOT NULL AUTO_INCREMENT, Topic varchar(255), Data varchar(255), Timestamp varchar(255), PRIMARY KEY(ID));&quot;;
  con.query(table, (err) =&gt; {
    if (err) {
      panic(err);
    } else {
      console.log(&quot;Table created!&quot;);
    }
  });
  
  app.get(&quot;*&quot;, (req, res) =&gt; {
    res.sendFile(path.join(__dirname, &quot;client/build&quot; , &quot;index.html&quot;));
  });
  
  
  app.listen(PORT, HOST);
  console.log(&quot;up!&quot;);
  </code></pre>