Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Commit

Permalink
Mount .erlang.cookie file
Browse files Browse the repository at this point in the history
Context: we want to move away from environment variables and use either
config files or env files (such as the rabbitmq-env.conf).

Since .erlang.cookie is neither, the official RabbitMQ Docker image
handles this by writing the value from the RABBITMQ_ERLANG_COOKIE env
var into the file if it does not exist. The problem is that if this file
exists, and the value is different from the RABBITMQ_ERLANG_COOKIE env
var, CLI tools will not be able to communicate with the rabbit node, as
described here: rabbitmq/rabbitmq-cli#443

The only gotcha is that this file must be owned by the user, and
privileges should not be too open (git should have captured this). If
not, RabbitMQ will fail to boot. This is somewhat similar to how OpenSSH
reacts when private key permissions are too open.

re docker-library/rabbitmq#422 (comment)

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
  • Loading branch information
gerhard committed Jul 1, 2020
1 parent 2bf26ba commit c4b04ea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docker/docker-compose-dist-tls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ services:
cap_add:
- ALL
hostname: rmq0-dist-tls
environment:
RABBITMQ_ERLANG_COOKIE: rmq0-dist-tls
# environment:
# RABBITMQ_LOG: debug,+color
volumes:
- ./erlang.cookie:/var/lib/rabbitmq/.erlang.cookie
- ./rabbitmq-dist-tls.conf:/etc/rabbitmq/rabbitmq.conf:ro
- ./rabbitmq-env.conf:/etc/rabbitmq/rabbitmq-env.conf:ro
- ./rabbitmq-ssl_dist.config:/etc/rabbitmq/ssl_dist.config:ro
Expand Down
5 changes: 3 additions & 2 deletions docker/docker-compose-overview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ services:
cap_add:
- ALL
hostname: rmq0
environment:
RABBITMQ_ERLANG_COOKIE: rabbitmq-overview
# environment:
# RABBITMQ_LOG: debug,+color
volumes:
- ./erlang.cookie:/var/lib/rabbitmq/.erlang.cookie
- ./rabbitmq-overview.conf:/etc/rabbitmq/rabbitmq.conf:ro
- ./rabbitmq-overview-definitions.json:/etc/rabbitmq/rabbitmq-definitions.json:ro
# we want to simulate hitting thresholds
Expand Down
5 changes: 3 additions & 2 deletions docker/docker-compose-qq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ services:
cap_add:
- ALL
hostname: rmq0-qq
environment:
RABBITMQ_ERLANG_COOKIE: rabbitmq-qq
# environment:
# RABBITMQ_LOG: debug,+color
volumes:
- ./erlang.cookie:/var/lib/rabbitmq/.erlang.cookie
- ./rabbitmq-qq.conf:/etc/rabbitmq/rabbitmq.conf:ro
- ./rabbitmq-qq-env.conf:/etc/rabbitmq/rabbitmq-env.conf:ro
- ./rabbitmq-qq-definitions.json:/etc/rabbitmq/rabbitmq-definitions.json:ro
Expand Down
1 change: 1 addition & 0 deletions docker/erlang.cookie
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rabbitmq-prometheus

2 comments on commit c4b04ea

@wainwrightmark
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid that this commit seems to have broken this tutorial for me https://www.rabbitmq.com/prometheus.html#quick-start
I'm running docker linux containers on a windows machine.
When I ran docker-compose-overview.yml docker asked to share elang.cookie, refusing stopped the process and saying yes caused the rabbit containers to fail with cookie file must be accessible by owner only

Reverting this commit on my local copy of the repository solved the issue and it works fine.

I imagine the issue is with how git sets the permissions on windows but I'm not sure how to fix that. Another solution might be to make a note in the tutorial about how to manually adjust the permissions.

Have a good day!

@gerhard
Copy link
Contributor Author

@gerhard gerhard commented on c4b04ea Jul 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @wainwrightmark, fixed via 7b5a876 👍🏻

Please sign in to comment.