Under [Docker] Windows host environment, to share or upload files to the container method

If that demand.

Solution 1-- mount directory ( applies to creating a new container )

Format
-v -v local directory or directory container: container directory

Examples
under Linux host environment: Mirroring nginx: latest, background mode starts a container, the container port 80 is mapped to the host port 80, the directory of the host / data mapped to the container / data.

docker run -p 80:80 -v /data:/data -d nginx:latest

Under Windows host environment:

docker run -it -v /d/WindowsFolder:/demo nginx:latest bash

Docker loading Windows folder to the vessel:
/ D / WindowsFolder folder path corresponding to host D: \ WindowsFolder;
/ demo vessel corresponding to the target path;
content / demo folder in the container is modified host D: \ contents WindowsFolder folder.

Reference material

https://www.cnblogs.com/ivictor/p/4834864.html
https://www.runoob.com/docker/docker-run-command.html

 

Solution 2 - copy files ( applies to have finished creating the container )

1. Start the container, or the configuration file receiving path acknowledgment

Docker PS - A 
Docker ID Start container or container name 
Docker Exec - IT ID container or container name the bash
 mkdir Demo

2. Close the container

docker stop container or container name ID

3. Perform copy

Docker CP D: \ FileNeedUploadToDocker.txt container or containers ID Name: / opt / Demo 
Docker ID Start container or container name 
Docker Exec - IT ID container or container name the bash 
CD opt / Demo /
 the dir

Reference material

https://blog.csdn.net/hou_ge/article/details/102485691

Guess you like

Origin www.cnblogs.com/jinzesudawei/p/11874833.html