docker-ip2location-mysql icon indicating copy to clipboard operation
docker-ip2location-mysql copied to clipboard

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

docker-ip2location-mysql

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

Usage

  1. Run this image as daemon using the download token and product code from IP2Location LITE or IP2Location.

    docker run --name ip2location -d -e TOKEN={DOWNLOAD_TOKEN} -e CODE={DOWNLOAD_CODE} -e MYSQL_PASSWORD={MYSQL_PASSWORD} ip2location/mysql
    

    ENV VARIABLE

    TOKEN - Download token obtained from IP2Location.

    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.

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

  2. The installation may take seconds to minutes depending on your database sizes, downloading speed and hardware specs. You may check the installation status by viewing the container logs. Run the below command to check the container log:

     docker logs -f ip2location
    

    You should see the line of => Setup completed if you have successfully complete the installation. Also, you should notice the generated password for the MySQL admin login as below:

     mysql -u admin -p{MYSQL_PASSWORD} ip2location_database
    

    Please write down the password somewhere else, as you will need it later for MySQL connection.

Connect IP2Location database from a container

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

Please note that --link flag has become the legacy feature of Docker and may eventually be removed. Please use the network bridge to link containers for query. You can read this article of How to connect IP2Location MySQL docker in Debian container to learn more.

Query for IP information

Below is an example of how to lookup for information of 8.8.8.8 IP address.

mysql -u admin -p{MYSQL_PASSWORD} -h ip2location-db ip2location_database -e 'SELECT * FROM `ip2location_database` WHERE INET6_ATON("8.8.8.8") <= ip_to LIMIT 1'

Update IP2Location Database

To update your IP2Location database to latest version, please run the following command:

docker exec -it ip2location ./update.sh

Articles and Tutorials

You can visit the below link for more information about this docker image: IP2Location Articles and Tutorials