Skip to content

Using Docker

Stefan Appelhoff edited this page Aug 12, 2021 · 3 revisions

Docker image available!

Docker

UPDATE 2021

Everybody looking into this, should rather have a look at: https://github.com/mne-tools/mne-docker/

Quickstart

After installing docker, run one of the following:

  • docker run -ti --rm sappelhoff/mne_bids:latest --version
  • docker run -ti --rm sappelhoff/mne_bids:latest --help

NOTE: This will download the mne_bids docker image from Docker Hub.

Introduction

A docker image for MNE-BIDS is available from Docker Hub and is continuously built from the docker branch on @sappelhoff's fork.

See the Dockerfile and the .dockerignore file.

You can build the image yourself from the root of the mne-bids repo with the Dockerfile in place and docker installed by calling: docker build -t mne_bids .. The -t flag tags the resulting image as "mne_bids".

Else, you can simply pull the image from Docker Hub. In the following we prepend sappelhoff/ to mne_bids, and append :latest, resulting in sappelhoff/mne_bids:latest. This tells docker to pull the mne_bids image from sappelhoff's repository with the latest tag.

NOTE: Currently only the MNE-BIDS CLI is exposed in the docker image.

Usage

template: docker run -ti --rm -v path/to/data:data/ sappelhoff/mne_bids:latest

See here for a brief explanation of the commands:

  • docker run is the command to tell docker to run a certain docker image, usually taking the form docker run <IMAGENAME> <COMMAND>
  • the --ti flag means the inputs are accepted and outputs are printed to the terminal
  • the --rm flag means that the state of the docker container is not saved after it has run
  • the -v flag is adding your local data to the docker container (bind-mounts). Importantly, the input after the -v flag consists of three fields separated colons: :
    • the first field is the path to the directory on the host machine: /path/to/data
    • the second field is the path where the directory is mounted in the container
    • the third field is optional. Could be for example ro to specify that the mounted data is read only

Example

  • assuming that we have downloaded the MNE-testing data:
my_path=~/mne_data/MNE-testing-data/Brainvision/

ls $my_path

docker run -ti --rm -v $my_path:/app sappelhoff/mne_bids:latest cp -i test_NO.vhdr -o test_YES.vhdr -v

ls $my_path

NOTE: we mount $my_data to /app in the container, because /app is specified as the WORKDIR in the Dockerfile.

Known problems (to be fixed)

  • When working on files using mne_bids cp, the output files have a different owner and are thus "read only". You need to change the owner again using sudo chown.
  • The image is currently quite large in size ... could probably be improved with some Docker good practices.

Clean up

You can delete the docker image using docker image ls to list the image, and then passing the IMAGE_ID (something like e6741b268896) listed for sappelhoff/mne_bids to docker image rm.

To delete all your images and containers, you can use docker system prune -a (NOTE: use with care!)