Share Data with Containers
The file system of a container is isolated from its host system by design. To share data with a container, you can mount folders in the host system to the container using the-v
Docker option.
For example, suppose you have a folder on the client machine namedMyFolder
. This folder contains the subfolder namedMySubfolder1
, which contains a set of image files. The folder also contains the subfolderMySubfolder2
, where you want to save your postprocessed images.
The following option mounts the source folderMyFolder
and its subfolders to a target folder in the container,ContainerFolder
:
-v /MyMachineName/MyFolder:/ContainerFolder
Add this option when you execute thedocker run
command.
You can now access and save data within the container in the folderContainerFolder
. Saved data is available in the host in the folderMyFolder
. These files persist once the container is stopped. Note that modifying files from within the container overwrites the files on the host.
You can mount as many folders to the container as you need using additional-v
options.
Read and Write Cloud Data onAWS
If the host of the container is a remote machine on AWS®, you can upload your local data to Amazon S3™ S3 buckets and then access them from the remote host, for more information seeCreating, configuring, and working with Amazon S3 buckets.
If you have data stored in Amazon S3, you can access it directly from MATLAB®. For more information, seeWork with Remote Data(MATLAB).