Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save muhamedoufi/b6cf45066f0138af9c1f82e7c74e1568 to your computer and use it in GitHub Desktop.
Save muhamedoufi/b6cf45066f0138af9c1f82e7c74e1568 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:

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