Reputation: 387
I've hosted OSRM server: https://hub.docker.com/r/osrm/osrm-backend/
docker run -t -i --network="test-net" -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/indonesia-latest.osrm
And its working as I am getting following output when browsing it:
{"message":"URL string malformed close to position 1: \"\/\"","code":"InvalidUrl"}
The backend is made using Django and the following code is supposed to hit the OSRM server and give the response:
BACKEND_HOST = os.getenv('WEB_VRP_BACKEND_HOST', '<ip address of osrm hosted server>')
BACKEND_PORT = os.getenv('WEB_VRP_BACKEND_PORT', '5000')
request = 'http://' + BACKEND_HOST + ':' + BACKEND_PORT + '/table/v1/driving/'
Both OSRM and Django is hosted in the same server and same network. The backend is built using docker and run
docker run --name vrp-backend --network="test-net" -d -p 9012:8090 vrp-web-django
And when i hit the backend with this address and required parameters, i get status:invalid in Postman. The two containers don't seem to be communicating but both are in same network and same server.
http://<ip address>/vrp/parse
I created the test-net network which is bridged. And docker inspect also shows both container in same network. What could be the cause? Thanks
Upvotes: 0
Views: 1164
Reputation: 1343
Have you considered using docker-compose
? You would have an easier time building and running multiple containers with docker-compose build
and docker-compose up
. The yaml file can look something like this:
version: "2.2"
services:
vrp-backend:
restart: always
build: path/to/dockerfile # or image: image_name:latest
command: python3 manage.py runserver
ports:
- '9012:8090'
links:
- 'osrm:osrm'
osrm:
image: osrm/osrm-backend
command: osrm-routed --algorithm mld /data/indonesia-latest.osrm
This will create a default network for you and will connect the containers to it.
Upvotes: 1