title: ts-node app running using docker run but not docker compose
body: <p>Using this Dockerfile:</p>
  <pre><code>FROM node:14-alpine
  WORKDIR /usr/src/app
  COPY package*.json ./
  RUN npm install
  COPY . .
  RUN npm run build
  EXPOSE 3000
  CMD [&quot;npm&quot;, &quot;start&quot;]
  </code></pre>
  <pre><code>docker build -t ts-node-api .    
  docker run -it --entrypoint sh --expose 3000 -it ts-node-api
  </code></pre>
  <p>or</p>
  <pre><code>docker run --expose 3000 -it steve/ts-node-api     
  </code></pre>
  <p>works correctly, apart from not connected to the db, which is a later problem.</p>
  <p>However, run the same Dockerfile as such:</p>
  <pre><code>version: &quot;3&quot;
  services:
    mongo:
      image: mongo
      volumes:
        - ./data:/data/db
      ports:
        - &quot;27017:27017&quot;
    ts-node-api:
      depends_on:
        - mongo
      build:
        context: .
        dockerfile: services/ts-node-api/Dockerfile
      ports: 
        - 3000:3000
  </code></pre>
  <p>using docker compose results in:</p>
  <pre><code> =&gt; ERROR [6/6] RUN npm run build                                                                                                               0.3s
  ------                                                                                                                                               
   &gt; [6/6] RUN npm run build:
  #9 0.244 npm ERR! code ENOENT
  #9 0.244 npm ERR! syscall open
  #9 0.244 npm ERR! path /usr/src/app/package.json
  #9 0.245 npm ERR! errno -2
  #9 0.246 npm ERR! enoent ENOENT: no such file or directory, open '/usr/src/app/package.json'
  #9 0.246 npm ERR! enoent This is related to npm not being able to find a file.
  #9 0.246 npm ERR! enoent 
  #9 0.248 
  #9 0.249 npm ERR! A complete log of this run can be found in:
  #9 0.249 npm ERR!     /root/.npm/_logs/2022-08-26T18_29_26_477Z-debug.log
  </code></pre>
  <p>Any help would be greatly appreciated, thank you.</p>