Volumes

Docker containers are fully isolated. It is necessary to mount volumes in order to handle input/output files.
By default, Docker containers cannot access data on the host system. This means

  • You can’t use host data in your containers
  • All data stored in the container will be lost when the container exits

You can solve this in two ways:

  • -v /path/in/host:/path/in/container: This bind mounts a host file or directory into the container. Writes to one will affect the other. Note that both paths have to be absolute paths, so you often want to use`pwd`/some/path
  • -v volume_name:/path/in/container. This mounts a named volume into the container, which will live separately from the rest of your files. This is preferred, unless you need to access or edit the files from the host.
mkdir datatest
touch datatest/test
docker run --detach --volume $(pwd)/datatest:/scratch --name fastqc_container biocontainers/fastqc:v0.11.9_cv7 tail -f /dev/null
docker exec -ti fastqc_container /bin/bash
> ls -l /scratch
> exit