How to copy files to/from a container

  • Some tasks might require copying files from a local machine into a container or from a container to the local machine. The article describes how to perform these operations.
  • Consider the option defined below depending on your needs:
    • To copy a file from the local file system to a container, run the command for Docker container or Kubernetes pod, respectively:
      docker cp <src-path> <container>:<dest-path> 
      kubectl cp <src-path> <your-pod-name>:<dest-path> 
      For example:
      docker cp "C:\ProcDump\procdump64.exe" sitecore-xm1_cm_1:"C:\" 

    • To copy a file from the container to the local file system, use:
      docker cp <container>:<src-path> <local-dest-path> 
      kubectl cp <your-pod-name>:<src-path> <local-dest-path> 
      For example:
      docker cp sitecore-xm1_cm_1:"C:\inetpub\wwwroot\App_Data\logs" "C:\" 
    1. You can copy files between running containers and host file system when containers run with process isolation.
      Note that these operations are not supported for the Hyper V isolation mode. If Hyper V isolation is used the container must be stopped before copying the file.
    2. The files copied to containers using these approaches are removed once the container is recreated. To store copied files in containers on a permanent basis, build a custom Docker image according to the Docker official documentation.

Applies to:

CMS 6+

July 06, 2020
July 06, 2020


  • Containers