Skip to content

Instantly share code, notes, and snippets.

@AlexandraKapp
Last active May 3, 2024 08:53
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save AlexandraKapp/e0eee2beacc93e765113aff43ec77789 to your computer and use it in GitHub Desktop.
Save AlexandraKapp/e0eee2beacc93e765113aff43ec77789 to your computer and use it in GitHub Desktop.
How to set up your own OSRM backend with Docker on Windows

How to set up your own OSRM backend with Docker on Windows

The OSRM docker quick start provides a great explanation on how to set up the container: https://hub.docker.com/r/osrm/osrm-backend/

Yet - for Docker on Windows minor changes were necessary for me (otherwise I'd get "File not found" or "Permission" errors).

This is how it worked for me:

1. Pull the image

docker pull osrm/osrm-backend

2. Download OpenStreetMap extract

Download OpenStreetMap extracts for example from Geofabrik

e.g.

Save the OpenStreetMap extract in a folder you can access from the shared drive: e.g. if your shared drive is "C:" place it in a folder "C:/docker"

shared folder img

3. Pre-process extract

Pre-process the extract and start a routing engine HTTP server on port 5000.

Depending on what kind of routing you want to use, choose the profile accordingly:

  • car: car.lua

  • walking: foot.lua

  • bike: bicycle.lua

    docker run -t -v c:/docker:/data osrm/osrm-backend osrm-extract -p /opt/PROFILE.lua /data/CITY-latest.osm.pbf

So for car rides in Berlin use:

docker run -t -v c:/docker:/data osrm/osrm-backend osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf

Then run:

docker run -t -v c:/docker:/data osrm/osrm-backend osrm-partition /data/berlin-latest.osrm
docker run -t -v c:/docker:/data osrm/osrm-backend osrm-customize /data/berlin-latest.osrm

4. Start the Routing Engine

docker run --name osrm -t -i -p 5000:5000 -v c:/docker:/data osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm

Then the docker container should be running on http://127.0.0.1:5000/

Test request:

curl "http://127.0.0.1:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true"

To get the engine started a second time when you pick up your work, only the last container needs to be started again. If you named it (with the flag --name osrm), you can run:

docker start osrm

Futher useful links:

@JDittmerCOM
Copy link

Is there a way to write your own isochrone with it?
I already tried to make one with GPT, Claude.ai and Bard, but everything didn't work because the url doesn't work.
The AIs use either isochrone or table in the URL, but both don't work.
Does anyone of you have a solution to this? Is that even possible?

@VDU8
Copy link

VDU8 commented Jan 25, 2024

@AlexandraKapp What if I want curl "/foot/" or "/bicycle/" profiles how do I get that? I am trying to display the routes on a webpage this deafults to driving I did download bicycle and foot profiles lua's how do I use that to display routes all three of them at once

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment