Search code examples
dockerubuntu-18.04osrm

Not able to connect OSRM frontend with OSRM backend using docker in Ubuntu


I had used the following commands to process the osrm/backend:

$docker pull osrm/osrm-backend
$wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
$docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/berlin-latest.osm.pbf
$docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-partition /data/berlin-latest.osrm
$docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-customize /data/berlin-latest.osrm
$docker run -t -i -d -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm

Now osrm/backend gets processed. I can browse backend using this URL http://localhost:5000 After browsing, I got this on the page

{"message":"URL string malformed close to position 1: \"/\"","code":"InvalidUrl"}

Then I ran the following commands to process the osrm/frontend:

$docker pull osrm/osrm-frontend
$docker run -p 9966:9966 osrm/osrm-frontend

The osrm/frontend gets processed but when I am trying to browse the frontend using the URL http://localhost:9966 , I see that the frontend is not getting connected with the backend.

Where I went wrong or any step I missed?

osrm/backend
osrm/frontend


Solution

  • We need to run backend and frontend commands in 2 different screens parallely. There will be a small change in the frontend command: "$docker run -p 9966:9966 -e OSRM_BACKEND='http://localhost:5000' osrm/osrm-frontend"