GeoServer Docker Starter Guide
This blog is part one of Geoserver using docker series
GeoServer is an open source server application used for publishing and sharing geospatial data. It is written in Java and allows users to access, manage and share geospatial data using open standards. GeoServer supports a wide range of data formats such as PostGIS, GeoTIFF, Shapefiles, and KML among others. It provides a web interface for configuration and management, and can be easily integrated with various client applications like OpenLayers, Google Earth, and QGIS. GeoServer is highly customisable and extensible, with a robust plugin architecture that allows users to add new functionalities and features to the server.
How to scale and deploy GeoServer easily?
Implementation of Docker
Docker is a containerisation platform that enables developers to package their applications along with their dependencies into portable and lightweight containers. This feature of Docker helps in easy deployment of applications. Docker provides a consistent environment for the application to run in, irrespective of the underlying infrastructure. This ensures that the application behaves the same way in any environment, be it a developer’s laptop or a production server. With Docker, deploying an application becomes a simple and fast process, as the entire application stack can be packaged into a container and moved between environments with ease. Docker also supports container orchestration tools like Kubernetes, which helps in managing large-scale deployments of applications.
Using GeoServer via Docker
There are several reasons why using Docker for GeoServer can be beneficial:
- Portability: Docker allows you to package your GeoServer application and all its dependencies into a single container. This makes it easier to move the application between different environments, such as from a development machine to a production server, without worrying about compatibility issues.
- Consistency: Docker ensures that the GeoServer application runs consistently across different environments. This means that if the application runs without issues on your local machine, it should run without issues on a production server.
- Scalability: Docker allows you to easily scale your GeoServer application horizontally by running multiple containers on different machines. This can help improve performance and handle increased traffic.
- Versioning: Docker allows you to easily manage multiple versions of your GeoServer application by using different containers for each version. This means that you can test and deploy new versions of your application without affecting the existing production environment.
- Security: Docker provides a secure runtime environment for your GeoServer application, with isolation between containers and the host operating system. This can help protect your application from potential security vulnerabilities.
There are several GeoServer images available on Docker. In this Blog we’ll be having look at the Image built and maintained by Kartoza. Image can be found at DockerHub and Github.
There are 2 ways in which we can utilise docker capabilities.
Using docker image from docker hub
Create GeoServer Instance with default settings
To create a GeoServer instance with default settings simply run the following command
docker run -e GEOSERVER_ADMIN_USER=geobeyond -e GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver -p 8080:8080 kartoza/geoserver
Above command can be broken down as follows
docker run # run the image from local machine, if image is not present fetch it from docker hub
-e GEOSERVER_ADMIN_USER=geobeyond # Set geoserver admin username as `geobeyond`
-e GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver # Set geoserver admin password as `myawesomegeoserver`
-p 8080:8080 # connect port 8080 of local machine to port 8080 of docker VM
kartoza/geoserver # name of the docker image to run, in this case the Kartoza one
Once pulled successfully, a GeoServer instance will be initiated by spinning up Tomcat
This is the easiest way to spin up GeoServer latest instance using Docker.
Run older GeoServer version
The docker-geoserver repo supports various versions, which can be seen as per tags on dockerhub. e.g. to run 2.18.7 simply add it as tag at the end of Docker image name
docker run -e GEOSERVER_ADMIN_USER=geobeyond -e GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver -p 8090:8080 kartoza/geoserver:2.18.7
Add plugins to GeoServer
GeoServer has various useful stable and community plugins. Generally you can find all available plugins for your desired GeoServer version here.
Kartoza infrastructure supports plugins through the use of two environment variables in Docker commands. Using STABLE_EXTENSION
and COMMUNITY_EXTENSION
, we can pass list of extensions we are interested in.
E.g. Install mysql and css stable extensions and s3-geotiff and gwc-sqlite community extensions in latest GeoServer
docker run -e GEOSERVER_ADMIN_USER=geobeyond -e GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver -e STABLE_EXTENSIONS=mysql-plugin,css-plugin -e COMMUNITY_EXTENSIONS=s3-geotiff-plugin,gwc-sqlite-plugin -p 8080:8080 kartoza/geoserver
GeoServer will download all plugins and install as per list
Once image run successfully, check out stores to confirm if changes are reflected
Default docker image ships with following pre-installed plugins:
- vectortiles-plugin
- wps-plugin
- printing-plugin
- libjpeg-turbo-plugin
- control-flow-plugin
- pyramid-plugin
- gdal-plugin
- monitor-plugin
- inspire-plugin
- csw-plugin
Add sample data to geoserver
By default GeoServer will have no data in it. i.e. workspaces, stores, etc. all will be empty.
To add some default dummy data, we can pass the variable SAMPLE_DATA
as True
docker run -e GEOSERVER_ADMIN_USER=geobeyond -e GEOSERVER_ADMIN_PASSWORD=myawesomegeoserver -e SAMPLE_DATA=True -p 8080:8080 kartoza/geoserver
This will add dummy data as you can see below
So far we have seen how to pass few variables and spin up an instance of GeoServer quickly.
The kartoza/geoserver image has lot more to offer beyond these basic settings. In order to understand more about it, we would be creating our own docker-compose file. So that the variables can be arranged systematically and can be connected with other services such as NGINX, PostGIS, etc.