How to do it…

  1. If you want to start a vanilla server, just execute the following command:
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.0.0
  1. An output similar to the following will be shown:
7.0.0: Pulling from elasticsearch/elasticsearch
256b176beaff: Already exists
1af8ca1bb9f4: Pull complete
f910411dc8e2: Pull complete
0c0400545052: Pull complete
6e4d2771ff41: Pull complete
a14f19907b79: Pull complete
ea299a414bdf: Pull complete
a644b305c472: Pull complete
Digest: sha256:3da16b2f3b1d4e151c44f1a54f4f29d8be64884a64504b24ebcbdb4e14c80aa1
Status: Downloaded newer image for docker.elastic.co/elasticsearch/elasticsearch:7.0.0
  1. After downloading the Elasticsearch image, we can start a develop instance that can be accessed outside from Docker:
docker run -p 9200:9200 -p 9300:9300 -e "http.host=0.0.0.0" -e "transport.host=0.0.0.0" docker.elastic.co/elasticsearch/elasticsearch:7.0.0

You'll see the output of the ElasticSearch server starting.

  1. In another window/Terminal, to check if the Elasticsearch server is running, execute the following command:
docker ps

The output will be similar to the following:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b99b252732af docker.elastic.co/elasticsearch/elasticsearch:7.0.0 "/usr/local/bin/dock…" 2 minutes ago Up 2 minutes 0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp gracious_bassi
  1. The default exported ports are 9200 and 9300.