title: How to configure rabbitmq.config inside Docker containers?
body: <p>I'm using the official RabbitMQ Docker image (<a href="https://hub.docker.com/_/rabbitmq/" rel="noreferrer">https://hub.docker.com/_/rabbitmq/</a>) </p>
  
  <p>I've tried editing the <code>rabbitmq.config</code> file inside the container after running </p>
  
  <p><code>docker exec -it &lt;container-id&gt; /bin/bash</code></p>
  
  <p>However, this seems to have no effect on the rabbitmq server running in the container. Restarting the container obviously didn't help either since Docker starts a completely new instance.</p>
  
  <p>So I assumed that the only way to configure <code>rabbitmq.config</code> for a Docker container was to set it up before the container starts running, which I was able to partly do using the image's supported environment variables. </p>
  
  <p>Unfortunately, not all configuration options are supported by environment variables. For instance, I want to set <code>{auth_mechanisms, ['PLAIN', 'AMQPLAIN', 'EXTERNAL']}</code> in <code>rabbitmq.config</code>. </p>
  
  <p>I then found the <code>RABBITMQ_CONFIG_FILE</code> environment variable, which should allow me to point to the file I want to use as my conifg file. However, I've tried the following with no luck:</p>
  
  <pre><code>docker service create --name rabbitmq --network rabbitnet \
  -e RABBITMQ_ERLANG_COOKIE='mycookie' --hostname = "{{Service.Name}}{{.Task.Slot}}" \
  --mount type=bind,source=/root/mounted,destination=/root \
  -e RABBITMQ_CONFIG_FILE=/root/rabbitmq.config rabbitmq
  </code></pre>
  
  <p>The default <code>rabbitmq.config</code> file containing:</p>
  
  <pre><code>[ { rabbit, [ { loopback_users, [ ] } ] } ]
  </code></pre>
  
  <p>is what's in the container once it starts</p>
  
  <p>What's the best way to configure <code>rabbitmq.config</code> inside Docker containers?</p>