SoFunction
Updated on 2025-03-10

How to mount files/folders in Docker

Mounting mapping of Docker files/folders

The folder mount map of the host

docker run -it -v d:\dockr_attach\data:/data image_id

This command is executed in cmd

A docker container with an attachment folder will be created based on the image

d:\dockr_attach\data The host folder path, I have created the \dockr_attach\data directory on disk D
/data The container map folder will exist in the root directory (the same level as the home directory)
image_id Mirrored id Use the docker images command to view all images' ids

Copy host file/folder to container

docker cp d:\dockr_attach\data docker_name:/home/
d:\dockr_attach\data Host folder/file path
docker_name Note that it is the container name. I used the container id to copy it unsuccessfully. docker ps -a to view all container information
/home/ Home folder in the root directory in the container

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.