title: Configuring RabbitMQ management docker image with default setup & access UI
body: <h2>Background</h2>
  
  <p>I need to setup a <code>docker-compose</code> with a RabbitMQ service and my application. This RabbitMQ service needs to have 3 things to work properly:</p>
  
  <ul>
  <li>a user named "user1" with full permissions</li>
  <li>a vhost named "vhost1"</li>
  <li>inside "vhost1", I need an exchange called "Pizza"</li>
  </ul>
  
  <h2>What we tried</h2>
  
  <p>To achieve this we tried creating a folder in our project called  <code>rabbitmq</code> with the following files:</p>
  
  <p><strong>definitions.json</strong></p>
  
  <pre><code>{
      "rabbit_version": "3.6.6",
      "users": [
       {
        "name": "user1",
        "password_hash": "pass1",
        "hashing_algorithm": "rabbit_password_hashing_sha256",
        "tags": "administrator"
       }
      ],
      "vhosts": [
       {
        "name": "\/vhost1"
       }
      ],
      "permissions": [
       {
        "user": "user1",
        "vhost": "\/vhost1",
        "configure": ".*",
        "write": ".*",
        "read": ".*"
       }
      ],
      "parameters": [],
      "policies": [],
      "queues": [],
      "exchanges": [],
      "bindings": []
     }
  </code></pre>
  
  <p><strong>rabbitmq.conf</strong></p>
  
  <pre><code>loopback_users.guest = false
  listeners.tcp.default = 5672
  </code></pre>
  
  <p>We are mounting this folder using the <code>volumes</code> command from <code>docker-compose</code> using the following file:</p>
  
  <pre><code>version: '3'
  services:
    rabbit:
      image: rabbitmq:management
      ports:
        - "8080:15672"
        - "5672:5672"
      volumes: 
        - ${PWD}/rabbitmq:/etc/rabbitmq
  </code></pre>
  
  <h2>Problems</h2>
  
  <p>We are facing two issues at the moment:</p>
  
  <ol>
  <li>we are <strong>not</strong> creating the exchange called "Pizza". </li>
  <li>we cannot access the RabbitMQ management UI via <code>localhost:8080</code> even though we specify the mapping of this port in our <code>docker-compose</code> file.</li>
  </ol>
  
  <h2>Questions</h2>
  
  <ol>
  <li>How do we define an exchange for a vhost in the <code>defininitions.json</code> file? (where can I read about it?)</li>
  <li>Why can't we access the UI? What are we doing wrong?</li>
  </ol>