How can I map a local Windows folder to a Docker Linux container using Docker volumes? |
If you want to map a local folder in your Windows PC to a Linux container in your local Docker environment you can create a "Docker volume" and mount it to the container at the time the container is created and started using the docker run command. Please follow this procedure: 1.- Start the Docker console in your Windows PC. 2.- Open a CMD window in your Windows operating system and run the following command to create and start a Docker Linux container using the docker run command. This command, with the -v option will create a Docker volume that will be mounted to the container after it is started: docker run --name Container_name -it -v "Windows_folder_to_be_shared":/Destination_Linux_directory image_name where:
Please see an example of this command in the following screenshot: Important note:
2.- Once you are connected to a session in the Linux operating system of your container you can cd to the directory that you mapped and list the contents, which should correspond to the files that you have in the source Windows folder: |