GDAL Docker – How to Install Latest GDAL on Docker Image of CentOS: Complete Guide

centosdockergdalrrgdal

I am trying to install gdal latest version on a docker image of CentOS. Below is the minimal code.

# Start and connect . 
docker run --rm -it centos:latest bash
yum -y upgrade
yum -y install wget
yum groupinstall "Development Tools"

cd /tmp
wget http://download.osgeo.org/gdal/3.0.4/gdal-3.0.4.tar.gz
tar zxvf gdal-3.0.4.tar.gz
cd gdal-3.0.4/
./configure

At ./configure step, I am getting error. configure: error: PROJ 6 symbols not found. Ideally I would like to install gdal latest version just by using yum, i.e. without building it. I am looking for a solution that would either fix the mentioned issue of allow me to install the latest version using yum.

Best Answer

Posting what solved my issue. I wanted to install gdal version 2.0.x or above for R package sf. Usual yum install would install version 1.11.x. Hence, the need to build and install. I believe this should also work for anyone who wants to install gdal on RedHat machines.

docker run --rm -it centos:7 bash

yum -y install epel-release
yum -y groupinstall "Development Tools"
yum -y install proj

cd /opt/source
svn checkout https://svn.osgeo.org/gdal/branches/2.2/gdal/ gdal-trunk
cd gdal-trunk
mkdir build
./configure
# install into build dir
make install
# check gdal version
# (can also check built paths with --prefix --libs --dep-libs --datadir)
gdal-config --version

yum -y install udunits2-devel
yum -y install openssl-devel
yum -y install libjpeg-turbo-devel
yum -y install libcurl-devel
yum -y install proj.x86_64 proj-devel.x86_64 proj-epsg.x86_64 proj-nad.x86_64 geos*


echo "/usr/local/lib" >> /etc/ld.so.conf.d/libgdal-x86_64.conf
export LD_LIBRARY_PATH="/opt/source/proj-4.8.0/build/lib:$LD_LIBRARY_PATH"
export PATH="/opt/source/proj-4.8.0/build/bin:$PATH"
export LD_LIBRARY_PATH="/opt/source/gdal-trunk/build/lib:$LD_LIBRARY_PATH"
export PATH="/opt/source/gdal-trunk/build/bin:$PATH"
export PATH="/opt/source/gdal-trunk/swig/python/scripts:$PATH"
mkdir -p /opt/source/gdal-trunk/build/lib64/python2.6/site-packages
export
ldconfig

yum -y install R
R
> install.packages("sf")