# 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](/working-in-the-sandbox/quirks-and-features/navigating-the-sandbox.md).

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](https://www.finngen.fi/en/members/recordings/finngen-data-users-meeting-7th-september-2021).

For more tutorials visit Docker page [Best practices for writing Dockerfiles](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/) and see tutorial video [How to Get Started with Docker](https://www.youtube.com/watch?v=iqqDU2crIEQ).

If you like to use symbolic links with Docker, you can find tutorials for that e.g. from [MYP Java Docker Logging Symlink Hack](http://mvpjava.com/docker-logging-symlink-hack/).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.finngen.fi/working-in-the-sandbox/quirks-and-features/docker-images/how-to-mount-data-into-docker-container-image.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
