OSRM: Modifying bicycle.lua - docker

I have set up OSRM (Open Source Routing Machine) on a Windows 11 machine with WSL (Ubuntu 20.04.1 LTS) and Docker installed.
docker pull osrm/osrm-backend
Using default tag: latest
latest: Pulling from osrm/osrm-backend
aed007321795: Pull complete
595e916ac67a: Pull complete
69f309e04f11: Pull complete
e73ad3e5bcf3: Pull complete
4c20f809069e: Pull complete
Digest: sha256:af5d4a83fb90086a43b1ae2ca22872e6768766ad5fcbb07a29ff90ec644ee409
Status: Downloaded newer image for osrm/osrm-backend:latest
docker.io/osrm/osrm-backend:latest
docker run -t -v /mnt/c/docker:/data osrm/osrm-backend osrm-extract -p /opt/bicycle.lua /data/south_west_highways.osm.pbf
docker run -t -v /mnt/c/docker:/data osrm/osrm-backend osrm-partition /data/south_west_highways.osrm
docker run -t -v /mnt/c/docker:/data osrm/osrm-backend osrm-customize /data/south_west_highways.osrm
docker run --name osrm -t -i -p 5000:5000 -v /mnt/c/docker:/data osrm/osrm-backend osrm-routed --algorithm mld /data/south_west_highways.osrm
It runs correctly and I'm able match bike GPX tracks to OSM ways.
I would now like to modify bicycle.lua to allow routes on 'main' roads - but I can't find /opt/bicycle.lua ?
https://github.com/Project-OSRM/osrm-backend/blob/master/profiles/bicycle.lua
Where should this file be located on my system?

I've found the answer! In the command
docker run -t -v /mnt/c/docker:/data osrm/osrm-backend osrm-extract -p /opt/bicycle.lua /data/south_west_highways.osm.pbf
just point to the new file that you want to refer to e.g.
docker run -t -v /mnt/c/docker:/data osrm/osrm-backend osrm-extract -p /my_location/my_lua_file.lua /data/south_west_highways.osm.pbf

Related

unable to build an osrm docker server for Brazil

I am trying to build my own docker server for Brazil. To do that I'm following this example. First I run this line of code:
docker pull osrm/osrm-backend
Then I download Brazil data from Geofabrik:
wget http://download.geofabrik.de/south-america/brazil-latest.osm.pbf
Pre-process the extract with the car profile:
docker run -t -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/brazil-latest.osm.pbf
But when I run the line of code above I only get one file which is the timestamps when I should get a lot more. However, when I run all commands for Berlin or Ireland (like in the example), I can successfully build my own server, I'm not sure why the same steps are not working for Brazil.
To build Berlin the following lines of code should be run:
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 -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/berlin-latest.osrm
I tried to follow that code (but with brazil-latest.osm.pbf and brazil-latest.osrm respectively), but I'm unable to extract all files from brazil-latest.osm.pbf. I'm not sure if there is a problem with Brazil or if there is something I am doing wrong.
Without knowing your system, it sounds like the classic problem that you don't have enough memory.
https://github.com/Project-OSRM/osrm-backend/wiki/Disk-and-Memory-Requirements
Also have a look at https://github.com/Project-OSRM/osrm-backend/issues/5265 there is a good discussion.
If that is your problem and you are running Linux consider using a swapfile for local extraction since they removed stxxl support in 5.23.0 (https://github.com/Project-OSRM/osrm-backend/pull/5760).
If you don't need the whole country you could also extract a smaller bounding box with tools like for example osmosis.

docker: why Failed to connect to seed

I run the following docker command. I don't understand why it is failed. Could you show me how to debug this? Thanks.
$ docker run -v `pwd`:/share -ti --name aerospike-aql --rm aerospike/aerospike-tools aql --host 192.168.1.191 --no-config-file
Unable to find image 'aerospike/aerospike-tools:latest' locally
latest: Pulling from aerospike/aerospike-tools
6ec7b7d162b2: Pull complete
177617b11d13: Pull complete
10273812b9e3: Pull complete
ac553cdb1df6: Pull complete
d633ea8cb425: Pull complete
1f91817a9ef3: Pull complete
403620a9a728: Pull complete
3a80741c7bbc: Pull complete
Digest: sha256:109801d7e8440dcf53461b13b55eaa96c1f86482209691285a34c6bb2fee4e1d
Status: Downloaded newer image for aerospike/aerospike-tools:latest
Seed: 192.168.1.191
User: None
Config File: None
2021-01-16 02:46:44 WARN Failed to connect to seed 192.168.1.191 3000. AEROSPIKE_ERR_CONNECTION Socket write error: 111, 192.168.1.191:3000
Error -10: Failed to connect
To add to Micah's comment I can suggest running again the server image, and then the command below that is not using the hardcoded host IP 192.168.1.191 but rather pulls it from the settings:
$ docker run --rm -tid --name aerospike -p 3000:3000 -p 3001:3001 -p 3002:3002 -p 3003:3003 aerospike/aerospike-server
$ docker run -v `pwd`:/share -ti --name aerospike-aql --rm aerospike/aerospike-tools aql --host $(docker inspect -f '{{.NetworkSettings.IPAddress }}' aerospike) --no-config-file

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
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"

Can't restore previous data after update

After updating my thingsboard docker image from v2.4.0 to v2.4.1, the new thingsboard container doesn't have any of my previous data, in my host dir I have the ~/.mytb-data directory with 8Gb of size, there is a way to restore that data to my container or another database, I really need to get that data from ~/.mytb-data
This is the docker image that I using: thingsboard/tb-cassandra
The update process:
$ docker pull thingsboard/tb-cassandra
$ docker stop mytb
$ docker run -it -v ~/.mytb-data:/data --rm thingsboard/tb-cassandra upgrade-tb.sh
$ docker rm mytb
$ docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v ~/.mytb-data:/data -v ~/.mytb-logs:/var/log/thingsboard --name mytb --restart always thingsboard/tb-cassandra

Unable to backup docker volumne

I'm following the offical docker guide from here to backup a docker volume. I'm also aware of this SO question however I'm still running into errors. Running the following command:
docker run --rm --volumes-from dbstore -v $(pwd):/backup ny_db_1 tar cvf /backup/backup.tar /dbdata
No matter what image name or container name or container id I put, I get the following error:
Unable to find image 'ny_db_1:latest' locally
The volume I want to backup:
$ docker volume ls
DRIVER VOLUME NAME
local ny_postgres_data
My containers:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
39e71e660eda postgres:10.1-alpine "docker-entrypoint.s…" 4 days ago Up 23 minutes 0.0.0.0:5434->5433/tcp ny_db_1
How do I backup my volume?
Update:
I tried the following but ran into a new error:
$ docker run --rm --volumes-from 39e71e660eda -v $(pwd):/backup postgres:10.1-alpine tar:local cvf /backup/backup.tar /dbdata
/usr/local/bin/docker-entrypoint.sh: line 145: exec: tar:local: not found
The docker run syntax is docker run [OPTIONS] IMAGE[:TAG|#DIGEST] [COMMAND] [ARG...] - ny_db_1 is the name of your container, docker will attempt to use the IMAGE "ny_db_1" which does not exist hence the error: "Unable to find image 'ny_db_1:latest' locally" (latest is the default [:TAG] if none is specified).
--volumes-from will mount volumes from the specified container(s) into a new container spawned from IMAGE[:TAG] for example: docker run --rm --volumes-from db -v $(pwd):/backup ubuntu:18.04 tar czvf /backup/backup.tar /dbdata
Note: if you're backing up a PostgreSQL database then imho you'd be better off using the appropriate tools to backup and restore the database for example:
Backup using pg_dumpall:
docker run --rm \
--name db-backup \
--entrypoint pg_dumpall \
--volume ${PWD}/backup:/backup \
--volumes-from db \
postgres:9 --host /var/run/postgresql --username postgres --clean --oids --file /backup/db.dump
Restore using psql:
docker run --rm -it \
-v ${PWD}/backup:/restore \
--name restore \
postgres:10.1-alpine
docker exec restore psql \
--host /var/run/postgresql \
--username postgres \
--file /restore/db.dump postgres
docker rename restore NEW_NAME
try this command here:
docker run -it --rm -v ny_postgres_data:/volume -v /tmp:/backup ny_db_1 \
tar -cjf /backup/ny_postgres_data -C /volume ./

Resources