Skip to content

Instantly share code, notes, and snippets.

@archaeogeek
Created April 23, 2020 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save archaeogeek/788199ae56c0d3a04d6bb7b420c7c64b to your computer and use it in GitHub Desktop.
Save archaeogeek/788199ae56c0d3a04d6bb7b420c7c64b to your computer and use it in GitHub Desktop.
Notes on setting up postgresql/postgis/elasticsearch/kibana in docker
# setup
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
wget -qO - https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
sudo apt -y install docker-ce
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $(whoami)
# useful commands
docker ps -a # shows all containers, running or not
docker log [containername] # shows what would be reported to stdout
docker stop/start/restart [containername] # stop/start/restart container with same params as it was initialised with (eg the run command)
docker inspect [containername] # inspect the config
docker rm [containername] # blast container into orbit
## PostgreSQL 9.5/PostGIS 2.5
# get image, create container, create volume
docker pull postgis/postgis:9.5-2.5-alpine
docker volume create pg_data9
# run it- note container name syntax is wrong, and it doesn't create the database (do that in pgcli later)
docker run --name=postgres9 -d -e POSTGRES_USER=user -e POSTGRES_PASS=password -e POSTGRES_DBNAME=gis -e ALLOW_IP_RANGE=0.0.0.0/0 -p 5432:5432 -v pg_datap:/var/lib/postgresql --restart=always postgis/postgis:9.5-2.5-alpine
# get the IP
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' postgres9
# connect via pgcli
pgcli -h IP -U user -W
create database geonetwork
pgcli -h IP d geonetwork -U user -W
create extension postgis
## ElasticSearch
# get the image
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.6.2
# run it
docker run --name=elasticsearch762 -d -p 9200:9200 -e "discovery.type=single-node" -v esdata:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:7.6.2
# checking it works
curl http://localhost:9200/\_cluster/health?pretty
## Kibana
# get the image
docker pull docker.elastic.co/kibana/kibana:7.6.2
# run it and link it to the elasticsearch container
docker run --name=kibana762 --link elasticsearch762:elasticsearch -d -p 5601:5601 -e "SERVER_BASEPATH=/geonetwork/dashboards" -e "SERVER_REWRITEBASEPATH=false" -e "KIBANA_INDEX=.dashboards" -e "ELASTICSEARCH_HOSTS=http://elasticsearch762:9200" docker.elastic.co/kibana/kibana:7.6.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment