- 1 year ago
Mapping folder in docker compose on Windows
To map a folder in Docker Compose on Windows, you can use the volumes
directive in your docker-compose.yml
file. Here's an example:
yamlversion: "3"
services:
my-service:
image: my-image
volumes:
- ./local-folder:/container-folder
In this example, ./local-folder
is the path to the folder on your local machine that you want to map, and /container-folder
is the path inside the container where you want to map it.
When you run docker-compose up
, Docker Compose will mount the ./local-folder
on your local machine to /container-folder
inside the container. Any changes made to files in the ./local-folder
will be reflected inside the container, and vice versa.
Note that on Windows, the path syntax for the local folder (./local-folder
) may vary depending on the shell you are using. The example above assumes you are using Git Bash or a similar shell. If you are using PowerShell, you may need to adjust the path syntax accordingly.
Also, make sure that the folder you are mapping (./local-folder
in this example) exists on your local machine before running docker-compose up
.
By mapping a folder using the volumes
directive in Docker Compose, you can easily share files and data between your local machine and the Docker container.