Reputation:
I want to sync my local folder with that of a docker container. I am using a windows system with Wsl 2 backend. I tried running the following command as per the instructions of a docker course instructor but it didn't seem to have synced it:
docker run -v ${pwd}:\app:ro --env-file ./.env -d -p 3000:4000 --name node-app node-app-image
Upvotes: 1
Views: 1759
Reputation: 1319
I faced a similar issue when I started syncing local folders with that of a docker container in my windows system. The solution was actually quite simple, instead of using -v ${pwd}:\app:ro
in your first volume it should be -v ${pwd}:/app:ro
. Notice the /
instead of \
. Since your docker container is a Linux container the path should have /
.
Upvotes: 1
Reputation: 384
As @Sysix pointed out, docker will always overwrite the folder in the container with the one on the host (no matter if it already existed or not). Only those files will be in that folder/volume that were created either on the host, or in the container during runtime.
Learn more about bind mounts and volumes here.
Upvotes: 0