Dockerfile source for RabbitMQ docker image.
This source repo was originally copied from: https://github.com/docker-library/rabbitmq
For Upstream documentation visit: https://github.com/docker-library/docs/tree/master/rabbitmq
This is not an official Google product.
This image contains an installation of RabbitMQ
For more information, see the Official Image marketplace Page.
Pull command:
gcloud auth configure-docker && docker -- pull marketplace.gcr.io/google/rabbitmq3Dockerfile for this image can be found here.
Replace your-erlang-cookie with a valid cookie value. For more information, see RABBITMQ_ERLANG_COOKIE in Environment Variable.
Copy the following content to pod.yaml file, and run kubectl create -f pod.yaml.
apiVersion: v1
kind: Pod
metadata:
name: some-rabbitmq
labels:
name: some-rabbitmq
spec:
containers:
- image: marketplace.gcr.io/google/rabbitmq3
name: rabbitmq
env:
- name: "RABBITMQ_ERLANG_COOKIE"
value: "unique-erlang-cookie"Run the following to expose the ports:
kubectl expose pod some-rabbitmq --name some-rabbitmq-4369 \
--type LoadBalancer --port 4369 --protocol TCP
kubectl expose pod some-rabbitmq --name some-rabbitmq-5671 \
--type LoadBalancer --port 5671 --protocol TCP
kubectl expose pod some-rabbitmq --name some-rabbitmq-5672 \
--type LoadBalancer --port 5672 --protocol TCP
kubectl expose pod some-rabbitmq --name some-rabbitmq-25672 \
--type LoadBalancer --port 25672 --protocol TCPFor information about how to retain your RabbitMQ data across container restarts, see Adding persistence.
Open an interactive shell to the RabbitMQ container. Note that because we open a shell directly in the container, Erlang cookie does not have to be explicitly specified.
kubectl exec -it some-rabbitmq -- /bin/bashrabbitmqctl can be run in the shell. For example, we can do a node health check.
rabbitmqctl node_health_check
We can store data on persistent volumes, this way the installation remains intact across restarts.
Copy the following content to pod.yaml file, and run kubectl create -f pod.yaml.
apiVersion: v1
kind: Pod
metadata:
name: some-rabbitmq
labels:
name: some-rabbitmq
spec:
containers:
- image: marketplace.gcr.io/google/rabbitmq3
name: rabbitmq
env:
- name: "RABBITMQ_ERLANG_COOKIE"
value: "unique-erlang-cookie"
volumeMounts:
- name: rabbitmq-data
mountPath: /var/lib/rabbitmq
volumes:
- name: rabbitmq-data
persistentVolumeClaim:
claimName: rabbitmq-data
---
# Request a persistent volume from the cluster using a Persistent Volume Claim.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: rabbitmq-data
annotations:
volume.alpha.kubernetes.io/storage-class: default
spec:
accessModes: [ReadWriteOnce]
resources:
requests:
storage: 5GiRun the following to expose the ports:
kubectl expose pod some-rabbitmq --name some-rabbitmq-4369 \
--type LoadBalancer --port 4369 --protocol TCP
kubectl expose pod some-rabbitmq --name some-rabbitmq-5671 \
--type LoadBalancer --port 5671 --protocol TCP
kubectl expose pod some-rabbitmq --name some-rabbitmq-5672 \
--type LoadBalancer --port 5672 --protocol TCP
kubectl expose pod some-rabbitmq --name some-rabbitmq-25672 \
--type LoadBalancer --port 25672 --protocol TCPReplace your-erlang-cookie with a valid cookie value. For more information, see RABBITMQ_ERLANG_COOKIE in Environment Variable.
Use the following content for the docker-compose.yml file, then run docker-compose up.
version: '2'
services:
rabbitmq:
container_name: some-rabbitmq
image: marketplace.gcr.io/google/rabbitmq3
environment:
"RABBITMQ_ERLANG_COOKIE": "unique-erlang-cookie"
ports:
- '4369:4369'
- '5671:5671'
- '5672:5672'
- '25672:25672'Or you can use docker run directly:
docker run \
--name some-rabbitmq \
-e "RABBITMQ_ERLANG_COOKIE=unique-erlang-cookie" \
-p 4369:4369 \
-p 5671:5671 \
-p 5672:5672 \
-p 25672:25672 \
-d \
marketplace.gcr.io/google/rabbitmq3For information about how to retain your RabbitMQ data across container restarts, see Adding persistence.
Open an interactive shell to the RabbitMQ container. Note that because we open a shell directly in the container, Erlang cookie does not have to be explicitly specified.
docker exec -it some-rabbitmq /bin/bashrabbitmqctl can be run in the shell. For example, we can do a node health check.
rabbitmqctl node_health_check
We can store data on persistent volumes, this way the installation remains intact across restarts. Assume that /path/to/your/rabbitmq is the persistent directory on the host.
Use the following content for the docker-compose.yml file, then run docker-compose up.
version: '2'
services:
rabbitmq:
container_name: some-rabbitmq
image: marketplace.gcr.io/google/rabbitmq3
environment:
"RABBITMQ_ERLANG_COOKIE": "unique-erlang-cookie"
ports:
- '4369:4369'
- '5671:5671'
- '5672:5672'
- '25672:25672'
volumes:
- /path/to/your/rabbitmq:/var/lib/rabbitmqOr you can use docker run directly:
docker run \
--name some-rabbitmq \
-e "RABBITMQ_ERLANG_COOKIE=unique-erlang-cookie" \
-p 4369:4369 \
-p 5671:5671 \
-p 5672:5672 \
-p 25672:25672 \
-v /path/to/your/rabbitmq:/var/lib/rabbitmq \
-d \
marketplace.gcr.io/google/rabbitmq3These are the ports exposed by the container image.
| Port | Description |
|---|---|
| TCP 4369 | epmd port, a peer discovery service used by RabbitMQ nodes and CLI tools. |
| TCP 5671 | Used by AMQP 0-9-1 and 1.0 clients with TLS. |
| TCP 5672 | Used by AMQP 0-9-1 and 1.0 clients without TLS. |
| TCP 25672 | Used by Erlang distribution for inter-node and CLI tools communication. This port is allocated from a dynamic range. By default, it takes the value of AMQP port plus 20000 (5672 + 20000), or 25672. |
These are the environment variables understood by the container image.
| Variable | Description |
|---|---|
| RABBITMQ_ERLANG_COOKIE | Sets the shared secret Erlang cookie used for authenticating other nodes and clients. For two nodes, or a node and a client, to communicate with each other, they must have the same Erlang cookie. |
| RABBITMQ_DEFAULT_USER | Sets the default user name. Used in conjunction with RABBITMQ_DEFAULT_PASS. Defaults to guest. |
| RABBITMQ_DEFAULT_PASS | Sets the default user password. Used in conjunction with RABBITMQ_DEFAULT_USER. Defaults to guest. |
These are the filesystem paths used by the container image.
| Path | Description |
|---|---|
| /var/lib/rabbitmq | All RabbitMQ files are installed here. |