How to mount data into Docker container image

Docker can be used to run applications and process the data in the container independently. This property also enables usage of tools otherwise not compatible with tools inside Sandbox IVM. Reading from input and writing to output data.

Here, as an example, we will copy a file inside a Docker container from input data to output data.

Open Terminal Emulatior in Sandbox. Pull docker from bioinformatics folder in Sandbox v3:

:~$ docker pull path/to/repository

An example:

:~$ docker pull eu.gcr.io/finngen-sandbox-v3-containers/bioinformatics:1.0.1

To list Docker images

:~$ docker images

returns

REPOSITORY                 TAG       IMAGE ID       CREATED       SIZE
path/to/repository     1.0.1      i1m2a3g4e5   2 years ago    3.91GB

Assign a name (here "tools") to the container and run docker attaching mounting, library-red and /home/ivm/ in background (-d option) keeping STDIN open (-i option) and allocating a pseudo-TTY (-t option).

:~$ docker run -dit --mount type=bind,source=/folder_where/your/targetfile_is/,target=/input_data,readonly --mount type=bind,source=/home/ivm/,target=/output_data --name tools i1m2a3g4e5

Source option will save your path to what you specify with target option.

To attach local standard input, output and error streams to a running container image and to check that the container is there:

:~$ docker attach tools

that will returns (if nothing seems to happen press enter again):

root@01r23o45o67t:/#

Copy data from input to output data (named here input_data and output_data) inside container:

root@01r23o45o67t:/# cp /input_data/file_name.txt output_data/

List folders in the container (Outputs your home/ivm content plus the file you copied using cp)

root@01r23o45o67t:/# ls output_data/

This will show list of folders and files in your output_data (here home/ivm) plus the file you just copied.

To exit container

root@01r23o45o67t:/# exit

Now the file you copied is found in "output_data" folder (in this example home/ivm/)

:~$ ls /home/ivm/

The copied folder is also visible in File Manager in Sandbox Desktop.

It should be noted that packages inside the Docker image can be used when attached to that image. Use of other sandbox tools outside Docker image is not possible when attached to the image.

See Samuel Jones user case of Docker image from FinnGen Users' meeting video 7th Sep 2021.

For more tutorials visit Docker page Best practices for writing Dockerfiles and see tutorial video How to Get Started with Docker.

If you like to use symbolic links with Docker, you can find tutorials for that e.g. from MYP Java Docker Logging Symlink Hack.

Last updated