Here are the steps needed to run a self hosted Open Street Map server (using Docker):
-
Download desired
pbf
files (likesouth-carolina-latest.osm.pbf
) from https://download.geofabrik.de or just use the following empty planet below:<?xml version='1.0' encoding='UTF-8'?> <osm version="0.6" generator="osmconvert 0.8.8" timestamp="2019-10-23T20:18:02Z"> <bounds minlat="42.4276" minlon="1.412368" maxlat="42.65717" maxlon="1.787481"/> </osm>
-
Download
osmconvert
from https://wiki.openstreetmap.org/wiki/Osmconvert. -
If you decided to use
empty-planet.osm
, we need to get it inpbf
format, so run:osmconvert empty-planet.osm -o=data.osm.pbf
-
If you decided to download some
pbf
files, we need to concatenate them together, so run (replacing thepbf
ando5m
file names where necessary):osmconvert south-carolina-latest.osm.pbf -o=south-carolina-latest.o5m osmconvert north-carolina-latest.osm.pbf -o=north-carolina-latest.o5m osmconvert south-carolina-latest.o5m north-carolina-latest.o5m -o=data.o5m osmconvert data.o5m -o=data.osm.pbf
-
Create a
Dockerfile
with the following content (in the same directory where yourdata.osm.pbf
is):FROM overv/openstreetmap-tile-server COPY data.osm.pbf /data.osm.pbf RUN /run.sh import VOLUME ["/var/lib/postgresql/12/main", "/var/lib/mod_tile"] ENTRYPOINT ["/run.sh", "run"]
See https://github.com/Overv/openstreetmap-tile-server for more information about the base image used.
-
Build the container:
docker build . -t osm-self-hosted
-
Run the container:
docker run -p 80:80 -p 5432:5432 --name osm-self-hosted -e ALLOW_CORS=1 -d osm-self-hosted run
Port
80
is for the client. Port5432
is for the database server.ALLOW_CORS=1
will enable CORS in case your client is served from a different domain. -
Navigate to http://localhost in your browser. A simple example client will show the map if everything worked properly.
-
You can connect to the database using pgAdmin with the following info:
- Host:
localhost:5432
- Maintenance database:
gis
- User/pass is
renderer
- Host: