Full Procedure : https://docs.docker.com/engine/install/ubuntu/
docker build https://github.com/SkydelSolutions/openstreetmap-tile-server.git -t osm
docker volume create osm-data
docker volume create osm-tiles
You can let the container download files itself by supplying the DOWNLOAD_PBF
environment variable. Additionally, you can also supply the DOWNLOAD_POLY
environment variable too. Though it is optional, but highly recommended.
If you want to download the map data yourself to give you more control over how much and how long and to keep it for reuse outside the container go to OSM Map Data Sources Wiki. The most commonly/frequently used source of less-than-the-whole-planet map extracts is Geofabrik. At Geofabrik you can download extracts of the latest whole planet map data by continent, country, country region, and where applicable state/province.
You can run this command again to download additional regions.
This container will stop once it is done.
docker run -e THREADS=8 -e "OSM2PGSQL_EXTRA_ARGS=-C 8192" -e DOWNLOAD_PBF=https://download.geofabrik.de/north-america/canada/quebec-latest.osm.pbf -e DOWNLOAD_POLY=https://download.geofabrik.de/north-america/canada/quebec.poly -v osm-data:/data/database/ -v osm-tiles:/data/tiles/ osm import
without network :
docker run -e THREADS=8 -e "OSM2PGSQL_EXTRA_ARGS=-C 8192" -v /home/user/Downloads/quebec-latest.osm.osm.pbf:/data/region.osm.pbf -v /home/user/Downloads/quebec.poly:/data/region.poly -v osm-data:/data/database/ -v osm-tiles:/data/tiles/ osm import
This will take a VERY long time to complete.
- 32 Thread
- 64 GB of RAM
- 1TB of SSD This container will stop once it is done.
docker run -e THREADS=32 -e "OSM2PGSQL_EXTRA_ARGS=-C 65536" -e "FLAT_NODES=enabled" -e DOWNLOAD_PBF=https://planet.openstreetmap.org/pbf/planet-latest.osm.pbf -v osm-data:/data/database/ -v osm-tiles:/data/tiles/ osm import
It is useful to pre-render all the tiles for the lower zoom levels first. This can be done with the following command:
# pre render all tiles on zoom levels 0 to 5
docker compose exec map-server render_list -a -f -z 0 -Z 5
OR
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
78343326830d openstreetmap-tile-server-aa-map-server "/run.sh run" 5 minutes ago Up 5 minutes 0.0.0.0:8080->80/tcp, [::]:8080->80/tcp osm-tile-server
$ docker exec -it 78343326830d /bin/bash
$ root@78343326830d:~# render_list -a -f -z 0 -Z 5
render_list
is a command that is part of the renderer inside the container.
# render_list --help
Usage: render_list [OPTION] ...
-a, --all render all tiles in given zoom level range instead of reading from STDIN
-f, --force render tiles even if they seem current
-m, --map=MAP render tiles in this map (defaults to 'default')
-l, --max-load=LOAD sleep if load is this high (defaults to 16)
-s, --socket=SOCKET unix domain socket name for contacting renderd
-n, --num-threads=N the number of parallel request threads (default 1)
-t, --tile-dir tile cache directory (defaults to '/var/cache/renderd/tiles')
-z, --min-zoom=ZOOM filter input to only render tiles greater or equal to this zoom level (default is 0)
-Z, --max-zoom=ZOOM filter input to only render tiles less than or equal to this zoom level (default is 20)
If you are using --all, you can restrict the tile range by adding these options:
-x, --min-x=X minimum X tile coordinate
-X, --max-x=X maximum X tile coordinate
-y, --min-y=Y minimum Y tile coordinate
-Y, --max-y=Y maximum Y tile coordinate
Without --all, send a list of tiles to be rendered from STDIN in the format:
X Y Z
e.g.
0 0 1
0 1 1
1 0 1
1 1 1
The above would cause all 4 tiles at zoom 1 to be rendered
The docker container can then be started as follows or using docker compose up -d
docker run -p 8080:80 -v osm-data:/data/database/ -v osm-tiles:/data/tiles/ -d osm run
in order for the file server to work on client devices you need to update this configuration file on the clients.
The IP should be the IP of the docker host. If you are running the tile server local to the system also running Skydel use the localhost address, i.e. 127.0.0.1.
nano /usr/lib/skydel-sdx/data/maps/earth/openstreetmap/openstreetmap.dgml
Windows:
C:\Program Files\Skydel\data\maps\earth\openstreetmap\openstreetmap.dgml
<downloadUrl protocol="https" host="a.tile.openstreetmap.org" path="/"/>
<downloadUrl protocol="https" host="b.tile.openstreetmap.org" path="/"/>
<downloadUrl protocol="https" host="c.tile.openstreetmap.org" path="/"/>
<downloadUrl protocol="http" host="127.0.0.1" port="8080" path="/tile/"/>
- Address: 127.0.0.1
- Transport Protocol : Http
- Port : 8080
This will start the container and import the specified OSM map data
docker run -v /osm_map_data/osm_pbf_data/us-south-latest.osm.pbf:/data/region.osm.pbf -v /osm_map_data/osm_pbf_data/us-south.poly:/data/region.poly -v /osm_map_data/osm_map_database:/data/database/ -v /osm_map_data/osm_map_tiles:/data/tiles 2ee1e4ce754b import
This will start the container in interactive mode with all the volume mounts and file mounts used during the import process. This is helpful when import fails.
docker run -v /osm_map_data/osm_pbf_data/us-south-latest.osm.pbf:/data/region.osm.pbf -v /osm_map_data/osm_pbf_data/us-south.poly:/data/region.poly -v /osm_map_data/osm_map_database:/data/database/ -v /osm_map_data/osm_map_tiles:/data/tiles --entrypoint /bin/bash -it 2ee1e4ce754b