Thanks @leungi. It’s actually a bit more complicated than that, and the help information is patchy and difficult to follow if you’re not a programmer. But here are the steps I took to get this working on Windows 10 Pro, hopefully they might be useful to anyone else hitting their head against a brick wall.
-
Install Docker for Windows Install Docker Desktop on Windows | Docker Docs
-
Enable CPU virtualization in BIOS, this will differ by machine How to Enable CPU Virtualization in Your Computer's BIOS If you don’t have Windows 10 Pro edition I’m not sure if you can complete this step, but this guy managed it somehow so check out his post Couldn't Process File data/osm_file.pbf during Docker Install Process - #7 by Dylansc22
-
In Docker Desktop (you may need to access its settings window from the icon in the system tray: right click → Settings) you need to go into Resources → File Sharing and add the folder where you want your files to live. For me it’s C:\Temp\Docker2 because I messed up the first time.
-
Now you can go to the windows command prompt (Windows key → cmd) and run this command which does a bunch of stuff behind the scenes which I don’t really understand:
docker pull openrouteservice/openrouteservice
-
Now it’s time to get some openstreetmap data as a pbf file. I used just Scotland [.osm.pbf] which I downloaded from here Geofabrik Download Server I saved that file to here C:\Temp\scotland-latest.osm.pbf
-
Now we need to run docker, there are instructions here but they didn’t make a lot of sense to me as a Windows user https://github.com/GIScience/openrouteservice/blob/main/docker/README.md
Evetually I figured out that I had to paste a command into the windows command line, and this is the one that worked:
docker run -dt --name ors-app -p 8080:8080 -v C:/Temp/Docker2/graphs:/ors-core/data/graphs -v C:/Temp/Docker2/elevation_cache:/ors-core/data/elevation_cache -v C:/Temp/Docker2/conf:/ors-conf -v C:/Temp/scotland-latest.osm.pbf:/ors-core/data/osm_file.pbf -e "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g" -e "CATALINA_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9001 -Dcom.sun.management.jmxremote.rmi.port=9001 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost" openrouteservice/openrouteservice:latest
You will obviously need to update the folder paths depending on your file structure, but you ought to be able to do that easily. Just use notepad to find/replace any instance of C:/Temp/Docker2…
- THIS IS REALLY IMPORTANT - If the command above worked, the command prompt will return a long string like this 8a405afe2d915f5376ce2e12afd1bc67bd56edc499742701cb656360daff846f
That’s a good sign, and although there’s no progress or confirmation, stuff is happening behind the scenes. Open Task Manager and check that Vmmem is using CPU and doing stuff. I think that docker is builing graphs (edges and nodes of your road network) but it does that silently. So don’t give up at this point or repeat the command. It’s incredibly unclear what’s going on at this stage but I guess once you know you know.
-
Now you can test it by opening a url like this in your browser http://localhost:8080/ors. The instructions talk about installing tomcat but I didn’t need to do this. Note that unless you have the Scotland data installed, this won’t work http://localhost:8080/ors/v2/directions/driving-car?start=-3.167209,55.974753&end=-3.398842,56.081019
-
The settings all live in a file called app.config in a directory called conf: C:\Temp\Docker2\conf\app.config
You can open this file in a text editor to change it. For example I increased the max distance from 100km to 1000km. However these settings won’t make any difference until you restart the docker container -
To restart the container you first need an id for your container. Back in windows command prompt type
docker container ls –aq
Now use the output to amend this command:
docker container restart 8a405afe2d91
Good luck! It’s an awesome tool, and it’s free so you can’t really complain, and the support here seems to be excellent. But the help and instructions for newbie windows users like me are poor. These links might be useful as there seems to be documentation in loads of different places:
https://github.com/GIScience/openrouteservice/blob/main/docker/README.md
https://hub.docker.com/r/openrouteservice/openrouteservice
https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/post
You may also see links to this page which doesn’t exist https://hub.docker.com/r/openrouteservice/docker/README.md