unable to build an osrm docker server for Brazil - docker

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.

Related

OSRM: Modifying bicycle.lua

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

make: *** No rule to make target 'build-x86_64'. Stop

I am following a tutorial series on yt https://www.youtube.com/watch?v=FkrpUaGThTQ
how to make an os soo
when in **Build for x86 ** use the command make build-x86_64 then it shows this error `
make: *** No rule to make target 'build-x86_64'. Stop.
`
I dont know how to fix it
Per the original YouTube author of the tutorial, this is the fix :
Try one of the following commands when entering the docker container from your host OS
For Linux, MacOS, WSL, etc :
docker run --rm -it -v "$pwd":/root/env myos-buildenv
docker run --rm -it -v "$PWD":/root/env myos-buildenv
docker run --rm -it -v "$(pwd)":/root/env myos-buildenv
Windows Powershell :
docker run --rm -it -v "${pwd}:/root/env" myos-buildenv
Windows CMD :
docker run --rm -it -v "%cd%":/root/env myos-buildenv
You just need to go back one directory by typing
"cd .."
then enter another command
"cd env" to move into the env folder
then you can enter "make build x86_64" command
Make the "MakeFile" file name as "makefile" and run the command "make build-x86_64"
Same problem I had. Just go on with Carey S.Turner`s answer.
Windows Powershell: docker run --rm -it -v "${pwd}:/root/env" myos-buildenv
Windows CMD: docker run --rm -it -v "%cd%":/root/env myos-buildenv
I had error with cmd but powershell worked fine for me.
I had the same error I found that it could be fixed by doing this bit right
Enter build environment:
Linux or MacOS: docker run --rm -it -v "$(pwd)":/root/env myos-buildenv
Windows (CMD): docker run --rm -it -v "%cd%":/root/env myos-buildenv
Windows (PowerShell): docker run --rm -it -v
"${pwd}:/root/env" myos-buildenv
Please use the linux command if you are using WSL, msys2 or git bash NOTE: If you are having trouble with an unshared drive, ensure your docker daemon has access to the drive you're development environment is in. For Docker Desktop, this is in "Settings > Shared Drives" or "Settings > Resources > File Sharing".
(https://github.com/davidcallanan/os-series/blob/ep1/README.md)
My error came out of me not doing the "$(pwd)" bit correctly

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"

Docker cannot connect to X server

I have created a docker image for opencv and facial reckognition to simplify the setup process.
But the recognize.py script needs X Server to show the image result. Here is what I have done so far:
sudo docker run -t -d --name opencv opencv:latest
sudo docker exec -it opencv bash /extract-embeddings.sh
sudo docker exec -it opencv bash /train-model.sh
All is fine so far. The last step is the actual comparison that displays the result in an image.
sudo docker exec -it opencv bash /face-recognition.sh
It gives the output:
[INFO] loading face detector...
[INFO] loading face recognizer...
No protocol specified
: cannot connect to X server :0
I have tried running the container with the following command:
sudo docker run -t -d --name opencv -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix opencv:latest
But it doesn't help.
Try running this,
xhost +
sudo docker run --rm -ti --net=host --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --env="QT_X11_NO_MITSHM=1" <image_name> <arguments>
Other might face issue regarding the image not getting rendered on screen or getting a blank screen with no image, for them add --env="_X11_NO_MITSHM=1" to the above script while running the docker image. It will solve the problem.
For further information, I would recommend you guys check out the below references.
Reference 1
Reference 2
It looks like the xauth is the issue for viewing of the image.
The details are at Can you run GUI applications in a Docker container?
It may happen that also the XAuthority is needed.
First, make sure that the host's $XAUTHORITY is defined.
And second, add the following parameters to the docker run command:
-v $XAUTHORITY:/tmp/.XAuthority -e XAUTHORITY=/tmp/.XAuthority
An example of a complete command:
sudo docker run --rm -ti --net=host --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $XAUTHORITY:/tmp/.XAuthority -e XAUTHORITY=/tmp/.XAuthority --env="QT_X11_NO_MITSHM=1" <image_name> <arguments>

Docker commiting changes overrides default start command

I have a jupyter notebook docker image from https://hub.docker.com/r/jupyter/datascience-notebook/.
Typically I run the notebook using this command
docker run -it --rm -p 8888:8888 -v /home/folder/Projects/:/home/jovyan/Projects -e NB_UID=1000 jupyter/datascience-notebook
This works perfectly and I am presented with the message that notebook is running. I am able to create notebooks, run them etc.
Now I want to install the jupyter contrib extenstions from https://github.com/ipython-contrib/jupyter_contrib_nbextensions. I followed the instructions here at: https://gist.github.com/glamp/74188691c91d52770807.
Using
docker run -it jupyter/datascience-notebook /bin/bash
command I am able to enter the container. Then I use pip and bash to install the package. All this goes smoothly.I exit the container and commit the changes using the container id.
docker commit containerid imagename
The problem is after committing the changes, when I run the container I am presented with bash prompt instead of the notebook start command.
Is there a way to commit package installation changes without changing the starting command of the image. Alternatively is there a way to edit the container image without actually running the image?
The problem is that you have committed a container that was started with the command /bin/bash.
What you need to is start the container normally using The command that you provided initially adding the -d option to free the terminal:
docker run -it --rm -d --name datascience-notebook -p 8888:8888 -v /home/folder/Projects/:/home/jovyan/Projects -e NB_UID=1000 jupyter/datascience-notebook
Then from the terminal exec into the container and install the contrib extenstions.
docker exec -it datascience-notebook /bin/bash
Exit the container and commit the image:
docker commit datascience-notebook <imagename>
Update:
In case the extension can't be installed when the container is running, the solution is to build a custom Docker image from using a Dockerfile
FROM jupyter/datascience-notebook
RUN <installation commands>
Finally build the image using docker build -t <image-name> . and run the image built.

Resources