Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Edited Docker install & tweaked Docker compose file. #47715

Merged
merged 12 commits into from
Nov 1, 2019
3 changes: 3 additions & 0 deletions docs/reference/redirects.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -920,3 +920,6 @@ See <<monitoring-overview>>.

See <<monitor-elasticsearch-cluster>>.

[role="exclude",id="docker-cli-run"]

See <<docker-cli-run-dev-mode>>.
186 changes: 98 additions & 88 deletions docs/reference/setup/install/docker.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ https://www.docker.elastic.co[www.docker.elastic.co].

endif::[]

[[docker-cli-run]]
==== Running {es} from the command line

[[docker-cli-run-dev-mode]]
===== Development mode
==== Starting a single node cluster with Docker

ifeval::["{release-state}"=="unreleased"]

Expand All @@ -55,75 +52,25 @@ endif::[]

ifeval::["{release-state}"!="unreleased"]

{es} can be quickly started for development or testing use with the following command:
To start a single-node cluster {es} for development or testing, specify
debadair marked this conversation as resolved.
Show resolved Hide resolved
<<single-node-discovery,single-node discovery>> to bypass the <<bootstrap-checks,bootstrap checks>>:

["source","sh",subs="attributes"]
--------------------------------------------
docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" {docker-image}
--------------------------------------------

Note the use of <<single-node-discovery,single-node discovery>> that allows bypassing
the <<bootstrap-checks,bootstrap checks>> in a single-node development cluster.

endif::[]

[[docker-cli-run-prod-mode]]
===== Production mode

[[docker-prod-prerequisites]]
[IMPORTANT]
=========================

The `vm.max_map_count` kernel setting needs to be set to at least `262144` for
production use. Depending on your platform:

* Linux
+
--
The `vm.max_map_count` setting should be set permanently in `/etc/sysctl.conf`:
[source,sh]
--------------------------------------------
$ grep vm.max_map_count /etc/sysctl.conf
vm.max_map_count=262144
--------------------------------------------

To apply the setting on a live system type: `sysctl -w vm.max_map_count=262144`
--

* macOS with https://docs.docker.com/engine/installation/mac/#/docker-for-mac[Docker for Mac]
+
--
The `vm.max_map_count` setting must be set within the xhyve virtual machine:
[[docker-compose-file]]
==== Starting a multi-node cluster with Docker compose

["source","sh"]
--------------------------------------------
$ screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
--------------------------------------------
The following Docker compose file brings up a three-node {es} cluster.
Node `es01` listens on `localhost:9200` and `es02` and `es03` talk to `es01` over a Docker network.

Just press enter and configure the `sysctl` setting as you would for Linux:

["source","sh"]
--------------------------------------------
sysctl -w vm.max_map_count=262144
--------------------------------------------
--

* Windows and macOS with https://www.docker.com/products/docker-toolbox[Docker Toolbox]
+
--
The `vm.max_map_count` setting must be set via docker-machine:

["source","txt"]
--------------------------------------------
docker-machine ssh
sudo sysctl -w vm.max_map_count=262144
--------------------------------------------
--
=========================

The following example brings up a cluster comprising two {es} nodes.
To bring up the cluster, use the
<<docker-prod-cluster-composefile,`docker-compose.yml`>> and just type:
The https://docs.docker.com/engine/tutorials/dockervolumes[Docker named volumes]
debadair marked this conversation as resolved.
Show resolved Hide resolved
`esdata01`, `esdata02`, and `esdata03` store the node data directories so the data persists across restarts.
If they don't already exist, `docker-compose` creates them when you bring up the cluster.

ifeval::["{release-state}"=="unreleased"]

Expand All @@ -134,6 +81,8 @@ endif::[]

ifeval::["{release-state}"!="unreleased"]

To bring up the cluster with <<docker-prod-cluster-composefile,`docker-compose.yml`>>, run:
debadair marked this conversation as resolved.
Show resolved Hide resolved

["source","sh"]
--------------------------------------------
docker-compose up
Expand All @@ -143,26 +92,12 @@ endif::[]

[NOTE]
`docker-compose` is not pre-installed with Docker on Linux.
Instructions for installing it can be found on the
https://docs.docker.com/compose/install/#install-using-pip[Docker Compose webpage].

The node `es01` listens on `localhost:9200` while `es02`
talks to `es01` over a Docker network.

This example also uses
https://docs.docker.com/engine/tutorials/dockervolumes[Docker named volumes],
called `esdata01` and `esdata02` which will be created if not already present.
For installation instructions, see
https://docs.docker.com/compose/install[Install Compose on Linux] on docs.docker.com.

[[docker-prod-cluster-composefile]]
`docker-compose.yml`:
ifeval::["{release-state}"=="unreleased"]

WARNING: Version {version} of {es} has not yet been released, so a
`docker-compose.yml` is not available for this version.

endif::[]

ifeval::["{release-state}"!="unreleased"]
`docker-compose.yml`:
["source","yaml",subs="attributes"]
--------------------------------------------
version: '2.2'
Expand All @@ -172,8 +107,8 @@ services:
container_name: es01
environment:
- node.name=es01
- discovery.seed_hosts=es02
- cluster.initial_master_nodes=es01,es02
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
Expand All @@ -192,8 +127,8 @@ services:
container_name: es02
environment:
- node.name=es02
- discovery.seed_hosts=es01
- cluster.initial_master_nodes=es01,es02
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
Expand All @@ -205,24 +140,99 @@ services:
- esdata02:/usr/share/elasticsearch/data
networks:
- esnet
es03:
image: {docker-image}
container_name: es03
environment:
- node.name=es03
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata03:/usr/share/elasticsearch/data
networks:
- esnet

volumes:
esdata01:
driver: local
esdata02:
driver: local
esdata03:
driver: local

networks:
esnet:
--------------------------------------------
endif::[]

To stop the cluster, type `docker-compose down`. Data volumes will persist,
so it's possible to start the cluster again with the same data using
`docker-compose up`.
To destroy the cluster **and the data volumes**, just type
To stop the cluster, run `docker-compose down`.
The data in the Docker volumes is preserved and loaded when when you restart the cluster with `docker-compose up`.
To **delete the data volumes** when you bring down the cluster, specify the `-v` option:
`docker-compose down -v`.

[[docker-cli-run-prod-mode]]
==== Using the Docker images in production

[[docker-prod-prerequisites]]
[IMPORTANT]
=========================

The `vm.max_map_count` kernel setting needs to be set to at least `262144` for
production use. Depending on your platform:

* Linux
+
--
The `vm.max_map_count` setting should be set permanently in `/etc/sysctl.conf`:
[source,sh]
--------------------------------------------
grep vm.max_map_count /etc/sysctl.conf
vm.max_map_count=262144
--------------------------------------------

To apply the setting on a live system type: `sysctl -w vm.max_map_count=262144`
--

* macOS with https://docs.docker.com/engine/installation/mac/#/docker-for-mac[Docker for Mac]
debadair marked this conversation as resolved.
Show resolved Hide resolved
+
--
The `vm.max_map_count` setting must be set within the xhyve virtual machine:

. From the command line, run:
+
["source","sh"]
--------------------------------------------
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty
--------------------------------------------

. Press enter and use`sysctl` to configure `vm.max_map_count`:
debadair marked this conversation as resolved.
Show resolved Hide resolved

["source","sh"]
--------------------------------------------
sysctl -w vm.max_map_count=262144
--------------------------------------------
--

* Windows and macOS with https://www.docker.com/products/docker-toolbox[Docker Toolbox]
debadair marked this conversation as resolved.
Show resolved Hide resolved
+
--
The `vm.max_map_count` setting must be set via docker-machine:

["source","txt"]
--------------------------------------------
docker-machine ssh
sudo sysctl -w vm.max_map_count=262144
--------------------------------------------
--
=========================

===== Inspect status of cluster:

["source","txt"]
Expand Down