Skip to content

6. Vectortiles via Docker Container

Dominik edited this page Jul 13, 2014 · 1 revision

Provide Tilemill2/Mapbox based Vectortilesseervices via Docker Containers

Providing an own TileServer with Docker

  • For providing an own tile server, you have to install and use docker:
  • Add keyserver to your server instance to allow docker install: sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
  • Get docker: sudo sh -c "echo deb http://get.docker.io/ubuntu docker main\> /etc/apt/sources.list.d/docker.list"
  • Check via cat /etc/apt/sources.list.d/docker.list if there is the content deb http://get.docker.io/ubuntu docker main\
  • Update package list: sudo apt-get update
  • Install docker: sudo apt-get install lxc-docker

Clone ma-tiles Repo:

  • Clone repository: https://github.com/ubergesundheit/ma-tiles
  • Check if there is a tm2z file. If not, copy a tm2z file in the ma-tiles folder and (if needed) adapt the server.coffee to link the right file (sudo nano server.coffee)
  • Allow access through firewall by adapting ufw: sudo nano /etc/default/ufw and change the line $ DEFAULT_FORWARD_POLICY="DROP" to $ DEFAULT_FORWARD_POLICY="ACCEPT"
  • Build the docker image sudo docker build -t tiles-v1 . (could also something like sudo docker build -t tiles-v2 .
  • Run and start the created docker image: sudo docker run -p 8001:80 -d tiles-v1 (where 8002 is the outside port and 80 the inside port)
  • Fetch tiles http://your-host/tiles/z/x/y.png or for instance http://localhost:8001/tiles/1/0/0.png

You can test the whole service for example here: http://www.leafletjs.com Open Browser Console and type: L.tileLayer('http://128.176.146.176:8001/tiles/{z}/{x}/{y}.png').addTo(map)

Some useful comands with Docker

  • list all running dockers: sudo docker ps -a
  • remove docker image: sudo docker rm <container ID>
  • stop docker: sudo docker stop <container ID>
  • start docker image (e.g. after restarting the machine): sudo docker start <container ID>
  • log a docker container: sudo docker logs <container ID>
  • list docker images: sudo docker images
  • delete docker images: sudo docker rmi -f <image ID>
  • Official docu help space: https://docs.docker.com/reference/commandline/cli/
  • More help here: https://gist.github.com/wsargent/7049221