title: How can I run an npm command in a docker container?
body: <p>I am trying to run an angular application in development mode inside a docker container, but when i run it with docker-compose build it works correctly but when i try to put up the container i obtain the below error:</p>
  
  <pre><code>
  
  ERROR: for sypgod  Cannot start service sypgod: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"npm\": executable file not found in $PATH
  
  </code></pre>
  
  <p>The real problem is that it doesn't recognize the command npm serve, but why??</p>
  
  <p>The setup would be below:</p>
  
  <p>Docker container (Nginx Reverse proxy -> Angular running in port 4000)</p>
  
  <p>I know that there are better ways of deploying this but at this moment I need this setup for some personals reasons</p>
  
  <p>Dockerfile:</p>
  
  <pre><code>
  FROM node:10.9 
  
  
  COPY package.json package-lock.json ./
  
  RUN npm ci &amp;&amp; mkdir /angular &amp;&amp; mv ./node_modules ./angular
  
  WORKDIR /angular
  
  RUN npm install -g @angular/cli 
  
  COPY . . 
  
  
  FROM nginx:alpine
  COPY toborFront.conf /etc/nginx/conf.d/
  EXPOSE 8080
  CMD ["nginx", "-g", "daemon off;"]
  CMD ["npm", "serve", "--port 4000"]
  
  </code></pre>
  
  <p>NginxServerSite</p>
  
  <pre><code>server{
      listen 80;
      server_name sypgod;
  
  
      location / {
              proxy_read_timeout 5m;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_pass http://localhost:4000/;
  
  
      }
  
  }
  
  
  </code></pre>
  
  <p>Docker Compose file(the important part where I have the problem)</p>
  
  <pre><code> sypgod: # The name of the service
          container_name: sypgod  # Container name
          build: 
              context: ../angular
              dockerfile: Dockerfile # Location of our Dockerfile
  
  
  </code></pre>