I'm having trouble getting my docker container to both sync volumes and autostart the dev environment.
To get volume syncing, allowing changes to code outside container to be reflected inside (while running) and vice versa; I've used the following within my docker-compose.yml:
volumes:
- ./frontend:/frontend
Which only works if my Dockerfile does't contain:
CMD ["npm", "run", "dev"]
If the CMD
line exists, I get the following error:
sh: vite: not found
Without the CMD
I can exec into the container and run the command manually, but I'm aiming to have it autostart. The autostart CMD
works sucessfully if the docker-compose.yml file doesn't contain the volume mapping.
I admit I'm completely new to both JS (and react) and docker, so I may have missed some key information. More than happy to provide anything requested. There are also several other threads within SO that seem similar, but alas every problem seems unique; I'm unable to ascertain where my problem is coming from; essentially why it can't find the vite command.
Thanks,
Wannabe Developer