Install MaxMind GeoIP REST API Inside Docker Container on Linux

Install MaxMind GeoIP REST API Inside Docker Container on Linux

MaxMind GeoIP REST API is a web service that allows users to look up geographical information based on an IP address. It provides details such as country, city, latitude, longitude, ISP, and more. This API is commonly used for geolocation, fraud prevention, and content customization. The service loads location information from MaxMind GeoLite2 database.

This tutorial explains how to install MaxMind GeoIP REST API inside a Docker container on Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install MaxMind GeoIP REST API

  • Host network

Run the following command to create a container for GeoIP REST API that uses host network:

docker run -d --name=geoip-api --restart=always --network=host \
    observabilitystack/geoip-api
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, GeoIP REST API service is listening on port 8080. It can be changed with -p option.

docker network create app-net
docker run -d --name=geoip-api --restart=always --network=app-net \
    -p 8081:8080 \
    observabilitystack/geoip-api

Testing MaxMind GeoIP REST API

The recommended method for querying the API is by making simple HTTP GET requests, providing the IP address as a path variable.

curl http://<IP_ADDRESS>:8080/8.8.8.8

Note: Replace <IP_ADDRESS> with the system's actual IP address.

Output example:

{
  "country": "US",
  "latitude": "37.751",
  "longitude": "-97.822",
  "continent": "NA",
  "timezone": "America/Chicago",
  "accuracyRadius": 1000,
  "asn": 15169,
  "asnOrganization": "GOOGLE",
  "asnNetwork": "8.8.8.0/24"
}

Uninstall MaxMind GeoIP REST API

To completely remove GeoIP REST API, remove its container:

docker rm --force geoip-api

Remove GeoIP REST API image:

docker rmi observabilitystack/geoip-api

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.