Transferring Files between host and container
With the SSH port, we can easily copy files between host and container.
For GNU/Linux and Mac users
You will use the build-in scp tool, and do not need to install an extra one. To copy file from container to host, issue the following command in the host terminal:
where
username
is the user name in Dockerfile. By default, it isics
.SRC_PATH
is the path of the file in container to copyHOST_PATH
is the path of the host to copy to
For example, the following command will copy a file in the container to a host path:
To copy file from host to container, issue the following command in the host terminal:
where
HOST_SRC_PATH
is the path of the host file to copyusername
is the user name in Dockerfile. By default, it isics
.DEST_PATH
is the path in the container to copy to
For example, the following command will copy a folder in Windows into the container:
For Windows users
Windows has no build-in scp
tool, and you have to download one manually. Download the latest release version of pscp.exe
here. Change the current directory of PowerShell to the one with pscp.exe
in it. Then use the following commands to transfer files.
The explanation of these commands is similar to scp
above. Refer to them for more information.
Last updated
Was this helpful?