The Docker.raw file contains all of the things, Containers, Images, and Volumes.
An Image, as you said, is a minimal operating system, along with whatever software it runs/needs. When you run it, a Container is created which provides disk space for the image. Containers can be easily discarded, so you don’t want to store data that you will need long-term in there. The answer to that, is to map folders within the Image to folders on your actual drive on you Mac. Use the -v command for that. When you run the Image, the folder in the Container becomes connected to the folder on your drive, and the Container uses it transparently.
I do this to process fMRI data. There is an image called niprep/fmriprep that I use.
As @mina said, I have this command that runs the Image with the appropriate folder mappings.
docker run -ti --rm \
-v /Volumes/fMRI/aim2/BIDS:/data:ro \
-v /Volumes/fMRI/aim2/BIDS/derivatives:/out \
-v /Volumes/fMRI/aim2/BIDS/work:/work \
nipreps/fmriprep:20.2.6 \
/data /out/fmriprep-20.2.6 \
sub-001 \
-w /work
This runs the docker Image and maps /Volumes/fMRI/aim1/BIDS
to /data
within the Container, and makes it read only (the :ro option).
It also maps /Volumes/fMRI/aim1/BIDS/derivatives
to /out
(again, in the Container), and /Volumes/fMRI/aim1/BIDS/work
to /work
(in the Container).
The Image to run is specified on the next line nipreps/fmriprep:20.2.6
.
The /data
and /out
folders are specified as where the data will come from and be saved to, the subject sub-001
is specified, then the work folder is specified.
There are also ways to run an Image and run a shell so that you get a #
prompt in the OS running in the container. So if I do that with the above command, then do ls -l
on the /data folder, I actually see the contents of /Volumes/fMRI/aim2/BIDS
:
Containers can also run various servers, such as a web server, or a jupyter notebooks server.
Endless possibilities!
One caveat: With Monterey installed, I found that my iMac Pro would shutdown without error or warning if I left Docker (or VMWare) running while I walked away for a while. I moved back to Big Sur, and everything is fine.