Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volume binding using docker compose on Windows

I recently upgraded my Docker Toolbox on Windows 10, and now my volume mounts no longer work. I've tried everything. Here is the current mount path:

volumes:   - C:\Users\Joey\Desktop\backend:/var/www/html 

I receive an invalid bind mount error.

like image 872
9997 Avatar asked Dec 26 '16 16:12

9997


People also ask

Can I use docker compose on Windows?

Docker Desktop is available for Mac, Windows and Linux. Install Compose plugin: (Mac, Win, Linux) Docker Desktop: If you have Desktop installed then you already have the Compose plugin installed.

Can docker compose create volumes?

We can also create a volume with Docker compose service or also specify existing volumes. For example, the following screenshot shows a 'docker-compose' file that creates a docker-compose service with a volume. As a result of the above command, a volume with the name 'myvolume' gets created.

How do I run a docker compose yml file in Windows?

To run and open . yml files you have to install Docker Compose. After the installation, go to your docker-compose. yml directory and then execute docker-compose up to create and start services in your docker-compose.

What is volume binding in docker?

This means that there is one behavior that is different between -v and --mount . If you use -v or --volume to bind-mount a file or directory that does not yet exist on the Docker host, -v creates the endpoint for you. It is always created as a directory.


2 Answers

  1. Share nfs path using docker settings

enter image description here 2. execute following command

docker run --rm -v c:/Users:/data alpine ls /data 
  1. Set path in docker compose file as shown below enter image description here

  2. File copied to windows

enter image description here

like image 59
Amit Jain Avatar answered Sep 20 '22 16:09

Amit Jain


Use:

volumes:   - "C:/Users/Joey/Desktop/backend:/var/www/html" 

Putting the whole thing in double quotes and using forward slashes worked for me. I was on windows 10 in windows 10 using Linux containers through WSL2

This answer was from Spenhouet given here.

like image 30
ylitc Avatar answered Sep 19 '22 16:09

ylitc