Skip to content

This is a pre-configured, ready-to-run PostgreSQL with IP2Location Geolocation database setup scripts. It simplifies the development team to install and set up the geolocation database in PostgreSQL.

ip2location/docker-ip2location-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

docker-ip2location-postgresql

This is a pre-configured, ready-to-run PostgreSQL with IP2Location Geolocation database setup scripts. It simplifies the development team to install and set up the geolocation database in PostgreSQL. The setup script supports the commercial database packages and free LITE package. Please register for a download account before running this image.

Usage

  1. Run this image as daemon with your download token and download code registered from IP2Location.

    docker run --name ip2location -d -e POSTGRESQL_PASSWORD=YOUR_POSTGRESQL_PASSWORD -e TOKEN=YOUR_TOKEN -e CODE=DOWNLOAD_CODE ip2location/postgresql
    

    ENV VARIABLE

    TOKEN - Download token form IP2Location account.

    CODE - Database code. Codes available as below:

    Free Database

    • DB1-LITE, DB3-LITE, DB5-LITE, DB9-LITE, DB11-LITE

    Commercial Database

    • DB1, DB2, DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, DB13, DB14, DB15, DB16, DB17, DB18, DB19, DB20, DB21, DB22, DB23, DB24, DB25

    IP_TYPE - (Optional) Download IPv4, IPv6 or both database. Script will download both database by default.

    • IPV4 - Download IPv4 database only.
    • IPV6 - Download IPv6 database only.
    • BOTH - Download IPv4 & IPv6 database.

POSTGRESQL_PASSWORD - (Optional) Password for PostgreSQL admin. A random password will be generated by default.

  1. The installation may take minutes to hour depending on your internet speed and hardware. You may check the installation status by viewing the container logs. Run the below command to check the container log:

     docker logs YOUR_CONTAINER_ID
    

    You should see the line of => Setup completed if you have successfully complete the installation.

Connect to it from an application

docker run --link ip2location:ip2location-db -t -i application_using_the_ip2location_data

Make the query

psql -h ip2location-db --username=postgres -d ip2location_database

Enter YOUR_POSTGRESQL_PASSWORD password when prompted.

Start lookup by following query:

SELECT * FROM ip2location_database WHERE inet_to_bigint('8.8.8.8') <= ip_to LIMIT 1;

Sample Code Reference

https://www.ip2location.com/tutorials

About

This is a pre-configured, ready-to-run PostgreSQL with IP2Location Geolocation database setup scripts. It simplifies the development team to install and set up the geolocation database in PostgreSQL.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published