Make sure to login to docker hub before getting started
$ docker login
# pull repo from docker hub
$ docker pull elasticsearch:latest
# run the container
# --name option is the reference for the container so that you can start and stop it after the initial run
# -p option are the ports to map the running container to. I use 127.0.0.1:9200 explicitly and supply :9200 as an extra precaution.
# -d is the image to run - the one you just downloaded above
$ docker run --name elasticsearch_latest -p 127.0.0.1:9200:9200 -d elasticsearch:latest
$ docker ps
# > container info for elasticsearch
$ curl -i localhost:9200
# you can stop the container now
$ docker stop elasticsearch_latest
# or start it
$ docker start elasticsearch_latest
# or list all containers (started or stopped)
$ docker ps -a