# Running VerneMQ using Docker

## Start a VerneMQ cluster node

{% hint style="danger" %}
To use the provided docker images the VerneMQ EULA must be accepted. See [Accepting the VerneMQ EULA](https://github.com/vernemq/vmq-docs/blob/2.0.0/installation/accepting-the-vernemq-eula.md) for more information.
{% endhint %}

```
docker run --name vernemq1 -d vernemq/vernemq
```

Sometimes you need to configure a forwarding for ports (on a Mac for example):

```
docker run -p 1883:1883 --name vernemq1 -d vernemq/vernemq
```

This starts a new node that listens on 1883 for MQTT connections and on 8080 for MQTT over websocket connections. However, at this moment the broker won't be able to authenticate the connecting clients. To allow anonymous clients use the `DOCKER_VERNEMQ_ALLOW_ANONYMOUS=on` environment variable.

```
docker run -e "DOCKER_VERNEMQ_ALLOW_ANONYMOUS=on" --name vernemq1 -d vernemq/vernemq
```

{% hint style="info" %}
Warning: Setting `allow_anonymous=on` completely disables authentication in the broker and plugin authentication hooks are never called! See more information about the authentication hooks [here](/plugin-development/sessionlifecycle.md#auth_on_register-and-auth_on_register_m5).
{% endhint %}

## Autojoining a VerneMQ cluster

This allows a newly started container to automatically join a VerneMQ cluster. Assuming you started your first node like the example above you could autojoin the cluster (which currently consists of a single container 'vernemq1') like the following:

```
docker run -e "DOCKER_VERNEMQ_DISCOVERY_NODE=<IP-OF-VERNEMQ1>" --name vernemq2 -d vernemq/vernemq
```

(Note, you can find the IP of a docker container using `docker inspect <CONTAINER_NAME> | grep \"IPAddress\"`).

## Checking cluster status

To check if the above containers have successfully clustered you can issue the `vmq-admin` command:

```
docker exec vernemq1 vmq-admin cluster show
+--------------------+-------+
|        Node        |Running|
+--------------------+-------+
|VerneMQ@172.17.0.151| true  |
|VerneMQ@172.17.0.152| true  |
+--------------------+-------+
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vernemq.com/installing-vernemq/docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
