title: Start the Nodejs and Docker then pass parameter to index.js in single statement
body: <p>I have written a program using the Node.js it uses the MySQL from the docker. Also, my node.js has the Index.js file which requires the input from the user based on which it will continue with different types of operation. In order to execute this, I need to run the following commands.</p>
  
  <p><code>1. docker-compose up --build -d</code>  which will start the various containers.</p>
  
  <p><code>2. docker-compose exec web sh -c "npm start"</code> which will start the Node.js application.</p>
  
  <p><code>3. one</code> parameter provided by the user which will be taken by index.js and based on the parameter different database operation can be performed.</p>
  
  <p>Now I wanted to remove these 3 different steps and merge them to make one so that users can provide just a single line query and it can be read and execution be started. Is there a way to merge these things and execute them all together.</p>
  
  <p>My <code>index.js</code> file looks something like this:</p>
  
  <pre><code>const   express     =   require('express');
  const   http        =   require("http");
  const   bodyParser  =   require('body-parser');
  const   app         =   express();
  const   basePath    =   __dirname;
  const   path        =   require('path');
  const   reqPath     =   path.join(__dirname, './');
  const   fs          =   require('fs');
  const   port        =   process.env.PORT || 9000;
  app.use(bodyParser.json()); 
  app.use(bodyParser.urlencoded({ extended: true }));
  
  //Make NodeJS to Listen to a particular Port in Localhost
  app.listen(port, function(){
  getInput(function(data){
  if(data.trim() === "Player")
  {
   console.log("ONE");
  }
  });
      });
  
  //function to take the input from the user and return it to calling function
  function getInput(callback)
  {
      var standard_input = process.stdin;
      standard_input.setEncoding('utf-8');
      standard_input.on('data', function (data) {
          callback(data);
      });
  }
  </code></pre>
  
  <p>Here is my <code>docker-compose.yaml</code> file with all the services:</p>
  
  <pre><code>version: '3'
  
  services:
    db:
      container_name: db
      image: mysql:5.7
      volumes:
        - "./data/mysql:/var/lib/mysql:rw"
      environment:
        MYSQL_DATABASE: database
        MYSQL_ROOT_PASSWORD: password
        MYSQL_USER: rootuser
        MYSQL_PASSWORD: password
        DATABASE_HOST: 127.0.01
      restart: always
  
    web:
      container_name: web
      image: node:8
      volumes:
        - ./web:/usr/src/app
      working_dir: /usr/src/app
      depends_on:
        - db
      restart: on-failure
      command: "tail -f /dev/null"
      environment:
        project: ${project}
        type: ${type}
  </code></pre>