The purpose of this repository is to make it easy to import MaxMind's GeoLite2/GeoIP2 CSV databases into a local Docker 🐳 container which is running PostgreSQL. This is meant to provide an easy way to query the CSV data in PostgreSQL. It's not meant as a solution to deploy to production.
- If you are on macOS, you will not need the
sudo
orsudo -E
form of the commands. - If you are on a later version of
compose
, you'll need to use the commanddocker compose
rather thandocker-compose
. - If you don't want to pass the license key at the command line, create
a file in the root of the repository called
.env
and add your key there.
A .env
file would look like:
MM_LICENSE_KEY=SEEKRIT
Before you get started, edit the DATABASES
variable in
bin/download/download-db.sh
. The currently tested list of databases is:
"GeoIP2-Anonymous-IP" "GeoLite2-City" "GeoIP2-Enterprise"
. Once you are happy
with this list you are ready to build the container.
sudo docker-compose build mm-dl
Run the following script, replacing the word SEEKRIT
with a MaxMind license
key.
MM_LICENSE_KEY=SEEKRIT sudo -E docker-compose up mm-dl
You may run this script as often as you like. It will download a database if none exists locally or if there is a newer version available to download.
sudo docker-compose build mm-pg
sudo docker-compose up --remove-orphans mm-pg
If you have psql
installed locally, use this command. When prompted for your password, enter "foo".
./bin/psql.sh
If you'd rather connect without a wrapper script, you can do something like:
psql -h localhost -U root -d mm_database
If you'd like to connect to the Docker container directly, get the Docker
container ID by running docker ps
. You can then use the id in the following
command:
sudo docker-compose exec mm-pg bash
Once you're inside the container, use the same command as above:
psql -h localhost -U root -d mm_database