How to Run FreeSurfer(GUI) on Windows with Docker



Docker Desktop for Windows, WSL2 must be installed to follow the practice below. 


1. Obtain a FreeSurfer License Key

Obtain a license key from the FreeSurfer homepage.


2. Place license key

I placed a license key in C:\nsimg\freesurfer


3. Create a Dockerfile

# Pull cgvalle/freesurfer_vnc:latest 
FROM cgvalle/freesurfer_vnc:latest  
# Copy the license.txt to the docker's /root/freesurfer 
COPY license.txt /root/freesurfer

        


4. Build an Image with Dockerfile

Open a command prompt or powershell to run command below (in blue letter).

You should build where Dockerfile and license.txt are.

docker build -t fs_vnc .



docker images





5. Run fs_vnc image as a container

Run command below (in blue letters) at the command prompt or in the power shell.


docker run -d --name fs_vnc -e VNC_PASSWORD=fsvnc -e SUBJECTS_DIR=/root/persistent/subjects -v C:\\nsimg\\freesurfer:/root/persistent -p 6080:80 -p 5900:5900 cgvalle/freesurfer_vnc:latest
# --name : Container name
# -e : Set container environment variable
# -v : Volume mount (persistent disk settings, local storage to container storage)
# -p : Port forwarding (local port to container port)
# fs_vnc : Image name

docker ps




6. Open VNC Viewer

Open your browser, type localhost:6080 and enter password you set.

- password : fsvnc

You can view persistent volumes by clicking File Manager.



7. Run FreeView

Run LXTerminal




Execute command below.

cd /root/freesurfer
freeview


Now, You can see Freeview.





Appendix

Delete Docker Containers and Images

Run command at the Windows command prompt

# stop container  
docker stop fs  
 
# stop and delete container  
docker rm fs
 
# delete image
docker rmi fs_vnc

Create a shortcut for LXTerminal





댓글