Skip to content

GoogleCloudPlatform/rabbitmq-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rabbitmq-docker

Dockerfile source for RabbitMQ docker image.

Upstream

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

Disclaimer

This is not an official Google product.

About

This image contains an installation of RabbitMQ 3.x.

For more information, see the Official Image Marketplace Page.

Pull command:

gcloud docker -- pull marketplace.gcr.io/google/rabbitmq3

Dockerfile for this image can be found here.

Table of Contents

Using Kubernetes

Running RabbitMQ

Starting a RabbitMQ instance

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 TCP

For information about how to retain your RabbitMQ data across container restarts, see Adding persistence.

Connecting to a running RabbitMQ container

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/bash

rabbitmqctl can be run in the shell. For example, we can do a node health check.

rabbitmqctl node_health_check

Adding persistence

Running with persistent data volumes

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: 5Gi

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 TCP

Using Docker

Running RabbitMQ

Starting a RabbitMQ instance

Replace 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/rabbitmq3

For information about how to retain your RabbitMQ data across container restarts, see Adding persistence.

Connecting to a running RabbitMQ container

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/bash

rabbitmqctl can be run in the shell. For example, we can do a node health check.

rabbitmqctl node_health_check

Adding persistence

Running with persistent data volumes

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/rabbitmq

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 \
  -v /path/to/your/rabbitmq:/var/lib/rabbitmq \
  -d \
  marketplace.gcr.io/google/rabbitmq3

References

Ports

These 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.

Environment Variables

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.

Volumes

These are the filesystem paths used by the container image.

Path Description
/var/lib/rabbitmq All RabbitMQ files are installed here.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published