Skip to content

prerequisites

Erik Johnson edited this page Mar 29, 2016 · 20 revisions

OSM Tiles: Prerequisites

Install Docker via yum.

RHEL 6

Install Docker 1.7.1, the latest version in RHEL 6.

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
sudo yum clean  all
sudo yum --disablerepo="epel" update  nss
sudo yum update
sudo yum install docker-io
sudo service docker start

RHEL 7

Install Docker 1.8.2, the latest version in RHEL 7.

sudo yum install docker
sudo systemctl start  docker.service
sudo systemctl enable docker

Docker Privileges

Docker provides root access to the file system, and should be handled accordingly, cf. http://reventlov.com/advisories/using-the-docker-command-to-root-the-host.

You can either:

  1. Prefix docker and docker-compose commands w/ sudo

  2. Or add a docker group and add your user to it.

     sudo groupadd docker
     sudo usermod -aG docker `whoami`

Install Docker Compose by downloading it as a shell script. Docker Compose 1.5.2 is the latest version compatible w/ Docker 1.7.1 and 1.8.2, which are currently the latest respective versions in RHEL 6 and 7.

curl -L https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname -s`-`uname -m` \
  > /tmp/docker-compose
chmod +x /tmp/docker-compose
sudo mv /tmp/docker-compose /usr/bin/docker-compose

Configure Docker Compose

Docker Compose uses a configuration file, docker-compose.yml, to allow Docker commands to be executed in a shorter and friendlier syntax, among other things.

Configure docker-compose.yml to provide a service named osm that is based on our osm-tiles image, w/ volume mounts to persist data to the host system and environment variables that will be passed to the running instance of the image:

osm:
  image: ncareol/osm-tiles
  volumes:
    # keep postgresql database files on host in ./docker/osm:
    - ./docker/osm/postgresql:/var/lib/postgresql
    # keep OSM tiles on host in ./docker/osm:
    - ./docker/osm/mod_tile:/var/lib/mod_tile
    # mount OSM data file from host into Docker container
    - ./planet-latest.osm.pbf:/tmp/planet-latest.osm.pbf
  environment:
    OSM_IMPORT_FILE: '/tmp/planet-latest.osm.pbf'
    OSM_IMPORT_CACHE: '900'
    OSM_MAX_ZOOM: '12'
    OSM_RENDER_FORCE: 'false'
  ports:
    - '8000:80'
  command: 'startweb'

For complete details on Docker-Compose file configuration, see the Compose file reference.

File Location and Volumes

Place the docker-compose.yml file in a directory from which you want to / can run the Docker Compose commands described in the instructions that follow. Some possible locations include:

  • /tmp
  • ~/
  • ~/osm-tiles

As configured above in the volumes section, commands will read and write from the directory in which the docker-compose.yml file is located and from which the Docker Compose commands are invoked. For importing the entire planet, this disk partition should have several hundred GB of free space:

  • tens of GB for the OSM file
  • ~400 GB for the Postgresql database
  • tens of GB for tiles when rendering up to zoom levels 12 or 13

There are several options for configuring volumes and the configuration provided here is a most basic example. For further options, see the official documentation for Docker volumes and Docker-Compose's volume configuration.

One suggested enhancement is to place the OSM file and Postgresql database on separate disks, so that one disk is reading the OSM file and another disk is writing the Postgresql database, rather than having a single disk as a potential bottleneck while handling both read and write operations. If /home and /mnt/data partitions are provided by separate disks and the OSM data is in ~/ads, then the configuration might look like:

  volumes:
    - /home/ads/planet-latest.osm.pbf:/tmp/planet-latest.osm.pbf
    - /mnt/data/docker/osm/postgresql:/var/lib/postgresql

SELinux

If SELinux is set to enforcing (see /etc/selinux/config), you will need to add :z to volumes that need to be writable, in this case:

    - ./docker/osm/postgresql:/var/lib/postgresql:z
    - ./docker/osm/mod_tile:/var/lib/mod_tile:z

Home | Next: Import »

Clone this wiki locally