Skip to content

Commit

Permalink
Update getting started Docker run command (#806)
Browse files Browse the repository at this point in the history
Update getting started Docker run command

Add HZ_NETWORK_PUBLICADDRESS to Docker run command

Fixes #805
  • Loading branch information
JackPGreen authored Aug 1, 2023
1 parent 5ac208b commit d3cabfe
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 25 deletions.
6 changes: 3 additions & 3 deletions docs/modules/deploy/pages/deploying-with-docker.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The default network mode in Docker is bridge. In this mode, all containers run i
- Host network mode (Linux only)
- Port mapping

WARNING: These methods open Hazelcast members to the public. Anybody who can reach the Docker host over the network can connect to Hazelcast ports of the running members.
include::deploy:partial$docker-ip-warning.adoc[]

=== Host Network Mode

Expand Down Expand Up @@ -104,15 +104,15 @@ hazelcast:
[source,bash,subs="attributes+"]
----
docker run --rm --name member1 \
-e "JAVA_OPTS=-Dhazelcast.local.publicAddress=192.168.1.12" -p 5701:5701 hazelcast/hazelcast:{full-version}
-e HZ_NETWORK_PUBLICADDRESS=192.168.1.12:5701 -p 5701:5701 hazelcast/hazelcast:{full-version}
----

. Start another member on the second host.
+
[source,bash,subs="attributes+"]
----
docker run --rm --name member1 \
-e "JAVA_OPTS=-Dhazelcast.local.publicAddress=192.168.1.13" -p 5701:5701 hazelcast/hazelcast:{full-version}
-e HZ_NETWORK_PUBLICADDRESS=192.168.1.13:5701 -p 5701:5701 hazelcast/hazelcast:{full-version}
----

In the member logs, you should see that your members connected to each other:
Expand Down
1 change: 1 addition & 0 deletions docs/modules/deploy/partials/docker-ip-warning.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WARNING: These methods open Hazelcast members to the public. Anybody who can reach the Docker host over the network can connect to Hazelcast ports of the running members and perform actions - such as data manipulation or shutting down the members.
14 changes: 9 additions & 5 deletions docs/modules/getting-started/pages/blue-green.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ Run the following command on the terminal:
docker run \
--network hazelcast-network \
--rm \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5701 \
-e HZ_CLUSTERNAME=blue \
-e HZ_LICENSEKEY=<your license key> \ <1>
-p 5701:5701 hazelcast/hazelcast-enterprise:{full-version}
----
<1> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.
<1> Replace the `<host_ip>` placeholder with the IP address of your Docker host.
<2> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.

You should see your cluster name in the console along with the IP address of the Docker container that's running the Hazelcast member.
You should see your cluster name in the console along with the IP address of the Docker host that's running the Hazelcast member.

[source,shell,subs="attributes+"]
----
Expand All @@ -79,11 +81,13 @@ Start another local single-member cluster called `green`.
docker run \
--network hazelcast-network \
--rm \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5702 \
-e HZ_CLUSTERNAME=green \
-e HZ_LICENSEKEY=<your license key> \ <1>
-p 5702:5701 hazelcast/hazelcast-enterprise:{full-version}
----
<1> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.
<1> Replace the `<host_ip>` placeholder with the IP address of your Docker host.
<2> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.

See the `green` cluster is formed:

Expand Down Expand Up @@ -246,7 +250,7 @@ XML::
<1> Number of times that the client will try to reconnect to each cluster before shutting down.
+
In this failover configuration file, you are directing the client to connect to the clusters in the given order from top to bottom;
see xref:clients:java#ordering-of-clusters-when-clients-try-to-connect[Ordering of Clusters]. So, when you start the client
see xref:clients:java#ordering-of-clusters-when-clients-try-to-connect.adoc[Ordering of Clusters]. So, when you start the client
(see Step 4 below), it will initially connect to the `blue` cluster. Here is what may happen:

* When the `blue` cluster fails, the client attempts to reconnect to it four times.
Expand Down Expand Up @@ -384,5 +388,5 @@ move to the other tutorials. To shut down the cluster, close the terminals in wh

If you're interested in learning more about the topics introduced in this tutorial, see:

* xref:clients:java#blue-green-deployment-and-disaster-recovery[Blue-Green Deployment].
* xref:clients:java#blue-green-deployment-and-disaster-recovery.adoc[Blue-Green Deployment].
* xref:{page-latest-supported-mc}@management-center:clusters:client-filtering.adoc[Filtering Client Connections].
24 changes: 18 additions & 6 deletions docs/modules/getting-started/pages/get-started-docker.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@ Docker networks make it easier for you to connect to your cluster and add other

. To start a member, execute the Docker `run` command.
+
include::deploy:partial$docker-ip-warning.adoc[]
+
Replace the `<host_ip>` placeholder with the IP address of your Docker host.
+
[source,shell,subs="attributes+"]
----
docker run \
-it \
--network hazelcast-network \
--rm \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5701 \
-e HZ_CLUSTERNAME=hello-world \
-p 5701:5701 hazelcast/hazelcast:{full-version}
----
+
Hazelcast environment variables:
+
- `HZ_NETWORK_PUBLICADDRESS`: The public IP address of your Docker host.
- `HZ_CLUSTERNAME`: The name of your cluster.
+
Docker parameters:
Expand All @@ -47,7 +53,7 @@ Docker parameters:
- `--network`: Allows you to connect to clusters, using an alias.
- `-p`: Expose port 5701 to allow external clients to connect to the member's Docker container.

You should see your cluster name in the console along with the IP address of the Docker container:
You should see your cluster name in the console along with the IP address of the Docker host:

image:platform-cluster-name.png[Platform console displays the cluster name 'hello-world']

Expand All @@ -62,11 +68,11 @@ SQL::
--
. In a new terminal window, start the SQL shell.
+
Replace the `$DOCKER_IP` placeholder with the IP address of your member's Docker container.
Replace the `<host_ip>` placeholder with the IP address of your Docker host.
+
[source,shell,subs="attributes+"]
----
docker run --network hazelcast-network -it --rm hazelcast/hazelcast:{full-version} hz-cli --targets hello-world@$DOCKER_IP sql
docker run --network hazelcast-network -it --rm hazelcast/hazelcast:{full-version} hz-cli --targets hello-world@$<host_ip> sql
----
+
The `--targets` parameter tells the SQL shell to connect to the member at the given IP address in a cluster called `hello-world`.
Expand Down Expand Up @@ -356,11 +362,11 @@ SQL::
--
. In a new terminal window, start the SQL shell.
+
Replace the `$DOCKER_IP` placeholder with the IP address of your member's Docker container.
Replace the `<host_ip>` placeholder with the IP address of your Docker host.
+
[source,shell,subs="attributes+"]
----
docker run --network hazelcast-network -it --rm hazelcast/hazelcast:{full-version} hz-cli --targets hello-world@$DOCKER_IP sql
docker run --network hazelcast-network -it --rm hazelcast/hazelcast:{full-version} hz-cli --targets hello-world@<host_ip> sql
----
. Query all data in the map.
Expand Down Expand Up @@ -644,22 +650,28 @@ In this step, you add two more members to your cluster.

. Open a new terminal and execute the Docker `run` command again to start another member.
+
Replace the `<host_ip>` placeholder with the IP address of your Docker host.
+
NOTE: Each container must expose port 5701 from a different port on the host machine. On this member, port 5701 is exposed to port 5702 on the host machine.
+
[source,shell,subs="attributes+"]
----
docker run \
--name my-second-member --network hazelcast-network \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5702 \
-e HZ_CLUSTERNAME=hello-world \
-p 5702:5701 hazelcast/hazelcast:{full-version}
----

. Start another member.
+
Replace the `<host_ip>` placeholder with the IP address of your Docker host.
+
[source,shell,subs="attributes+"]
----
docker run \
--name my-third-member --network hazelcast-network \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5703 \
-e HZ_CLUSTERNAME=hello-world \
-p 5703:5701 hazelcast/hazelcast:{full-version}
----
Expand Down Expand Up @@ -721,4 +733,4 @@ Or, if you're interested in learning more about topics that we introduced in thi

- xref:{page-latest-supported-mc}@management-center:getting-started:overview.adoc[Management Center]

- xref:network-partitioning:network-partitioning.adoc[Network partitioning]
- xref:network-partitioning:network-partitioning.adoc[Network partitioning]
18 changes: 13 additions & 5 deletions docs/modules/getting-started/pages/persistence.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ You'll start the first member in a cluster called `hello-world`. Run the followi
docker run \
--name first-member --network hazelcast-network \
--rm \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5701 \
-e HZ_CLUSTERNAME=hello-world \
-e HZ_LICENSEKEY=<your license key> \ <1>
-e HZ_PERSISTENCE_ENABLED=true \ <2>
-e HZ_MAP_MYDISTRIBUTEDMAP_DATAPERSISTENCE_ENABLED=true \ <3>
-v ~/persist:/opt/hazelcast/persistence \ <4>
-p 5701:5701 hazelcast/hazelcast-enterprise:{full-version}
----
<1> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.
<2> The environment variable to enable the persistence feature for the member
<3> The environment variable to enable the persistence feature for a map
<4> By default, the persistence feature creates the `/opt/hazelcast/persistence` directory to store the persisted data.
<1> Replace the `<host_ip>` placeholder with the IP address of your Docker host.
<2> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.
<3> The environment variable to enable the persistence feature for the member
<4> The environment variable to enable the persistence feature for a map
<5> By default, the persistence feature creates the `/opt/hazelcast/persistence` directory to store the persisted data.
However, using a Docker image, you cannot create any files inside the container. This line of the command mounts a directory
on your local to the container, which in this case is `persist` under the home directory. This way, the container will use this local
directory to save the persisted data.
Expand All @@ -71,14 +73,19 @@ Your first member is started now, you can see from its terminal logs that persis

== Step 2. Start More Members

Run each of the following Docker commands in a separate terminal. Replace the `<your license key>` placeholders with your Hazelcast Enterprise license key.
Run each of the following Docker commands in a separate terminal.

Replace the `<host_ip>` placeholders with the IP address of your Docker host.

Replace the `<your license key>` placeholders with your Hazelcast Enterprise license key.

.Command to start a second member.
[source,shell,subs="attributes+"]
----
docker run \
--name second-member --network hazelcast-network \
--rm \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5702 \
-e HZ_CLUSTERNAME=hello-world \
-e HZ_LICENSEKEY=<your license key> \
-e HZ_PERSISTENCE_ENABLED=true \
Expand All @@ -94,6 +101,7 @@ docker run \
docker run \
--name third-member --network hazelcast-network \
--rm \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5703 \
-e HZ_CLUSTERNAME=hello-world \
-e HZ_LICENSEKEY=<your license key> \
-e HZ_PERSISTENCE_ENABLED=true \
Expand Down
11 changes: 5 additions & 6 deletions docs/modules/getting-started/pages/wan.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ which means it does not need WAN Replication to be configured. Run the following
----
docker run \
--network hazelcast-network \
-e HZ_NETWORK_PUBLICADDRESS=<host_ip>:5701 \
-e HZ_LICENSEKEY=<your license key> \ <1>
-e HZ_CLUSTERNAME=london \
hazelcast/hazelcast-enterprise:{full-version}
----
<1> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.
<1> Replace the `<host_ip>` placeholder with the IP address of your Docker host.
<2> Replace the `<your license key>` placeholder with your Hazelcast Enterprise license key.

The member is up and running now.

Expand All @@ -60,9 +62,6 @@ Members {size:1, ver:1} [
]
----

Note the member's IP address and port since you are going to use it to configure WAN
Replication for the active cluster and to connect to Management Center.

== Step 2. Start the Active Cluster

Now you'll start another Enterprise cluster called `tokyo` with a single member. This will be the **active** cluster
Expand All @@ -89,7 +88,7 @@ hazelcast:
batch-publisher:
londonPublisherId:
cluster-name: london
target-endpoints: 172.18.0.3:5701
target-endpoints: <host_ip>:5701
map:
cities: <1>
wan-replication-ref:
Expand All @@ -111,7 +110,7 @@ XML::
<batch-publisher>
<cluster-name>london</cluster-name>
<publisher-id>londonPublisherId</publisher-id>
<target-endpoints>172.18.0.3:5701</target-endpoints>
<target-endpoints>"host_ip":5701</target-endpoints>
<map name="cities">
<wan-replication-ref name="london-wan-rep">
</map>
Expand Down

0 comments on commit d3cabfe

Please sign in to comment.