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
sudoorsudo -Eform of the commands. - If you don't want to pass the license key at the command line, create
a file in the root of the repository called
.envand add your key there.
A .env file would look like:
MM_LICENSE_KEY=SEEKRITBefore 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-dlRun the following script, replacing the word SEEKRIT with a MaxMind license
key.
MM_LICENSE_KEY=SEEKRIT sudo -E docker compose up mm-dlYou 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-pgsudo docker compose up --remove-orphans mm-pgIf you have psql installed locally, use this command. When prompted for your password, enter "foo".
./bin/psql.shIf you'd rather connect without a wrapper script, you can do something like:
psql -h localhost -U root -d mm_databaseIf 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 bashOnce you're inside the container, use the same command as above:
psql -h localhost -U root -d mm_database