Same docker-compose.yml, but now working on Windows

  docker, docker-compose, dockerfile, windows

I am new to docker, and I am trying to run my Svelte project with docker.
This is my docker-compose.yml file:

version: '3.8'

services:
  app:
    build: .
    ports:
      - '3000:3000'
    volumes:
      - '.:/usr/src/app'
      - 'node_modules:/usr/src/app/node_modules'

volumes:
  node_modules:

And Dockerfile:

FROM node:14-alpine

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 3000

CMD ["npm", "start"]

This goes well on my Macbook, but it is not working on my Windows desktop. What is the reason?
And I solved this problem with fixing docker-compose.yml like this:

version: '3.8'

services:
  app:
    build: .
    ports:
      - '3000:3000'
    volumes:
      - '.:/usr/src/app'
      - '/usr/src/app/node_modules'

What is the difference between this code and previos docker-compose.yml?

Source: Docker Questions

LEAVE A COMMENT