With the SSH port, we can easily copy files between host and container.
For GNU/Linux and macOS 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:
HOST_SRC_PATH is the path of the host file to copy
username is the user name in Dockerfile. By default, it is oslab
DEST_PATH is the path in the container to copy to
For example, the following command will copy a folder in host 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.exehere. 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.
Have a try!
New a text file with casual contents in the host.
Copy the text file to the container.
Modify the content of the text file in the container.
Copy the modified file back to the host.
Check whether the content of the modified file you get after the last step is expected. If it is the case, you are done!