Hey there! I've been trying to dive into learning Docker, but I'm having trouble syncing the host and container using volumes when making changes and saving code (specifically using npm run dev). Every time I need to restart docker-compose up --build
for the "sync" to take effect, but even then any changes don't update the folder or code. Here's an example of my setup:
I installed Next.js with typescript as the base.
npx create-next-app@latest --ts
Here's my docker-compose config:
version: "3"
services:
node-myname:
build:
context: .
dockerfile: DockerFile.dev
ports:
- "3000:3000"
command: "npm run dev"
restart: always
volumes:
- .:/usr/src/home/node/app/
And here's my DockerFile:
FROM node:16
WORKDIR /home/node/app
COPY . .
RUN npm install
I know it's recommended to use volumes instead of bind mounts...
But unfortunately, I haven't been able to find a workaround yet. Any suggestions would be greatly appreciated!