title: RabbitMq Spring Boot deploy docker
body: <p>I've got a spring boot application with producer and receiver which uses the local rabbitmq to send and receive messages. I am trying to deploy both the app and rabbit on docker container and once deployed run the boot app. Once the app is started it has a producer which implements Spring CommandLineRunner meaning that the app immediately starts sending messages so there must be a rabbitmq broker running prior. I am very new to docker. I tried so far:</p>
  
  <p>1). I created image for the spring boot app as the following</p>
  
  <pre><code>FROM java:8
  EXPOSE 8080
  ADD /target/MessagingApp.jar MessagingApp.jar
  ENTRYPOINT ["java","-jar","MessagingApp.jar"]
  </code></pre>
  
  <p>2). Then created docker.compose file for rabbit and my newly created image</p>
  
  <pre><code>rabbitmq:
    image: rabbitmq:management
    ports:
      - "5672:5672"
      - "15672:15672"
  messagingapp:
    image: messagingapp:latest
    ports:
      - "80:8080"
    links:
      - rabbitmq
  </code></pre>
  
  <p>I then ran docker-compose up and I can see rabbit started to some extend and then spring boot app but fails sending messages with </p>
  
  <pre><code>at com.rabbitmq.client.impl.SocketFrameHandlerFactory.create..
  </code></pre>
  
  <p>I think my issue is that my spring boot app automatically tries to connect to the localhost rabbit host. So how do I make it point to the docker rabbitmq server?</p>
  
  <p>Any help?</p>