Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the rabbitmq docker compose yml file to build docker image?

I'm new to docker and I know how to pull images of Ubuntu Linux and run it. I just wish to try out rabbitmq, and the site says we can use a docker-composer.yml file like this:

rabbitmq:
  image: rabbitmq:management
  ports:
    - "5672:5672"
    - "15672:15672"

I googled for a while but only find YAML related sites talks about how to write a complex YAML file. But my question is, how to use this YAML file to build/compose any docker image with rabbitmq so that I can start to use it?

like image 202
Troskyvs Avatar asked Apr 28 '17 09:04

Troskyvs


2 Answers

here you can find a few examples:

https://github.com/Gsantomaggio/rabbitmqexample/tree/master/cluster_docker_compose

version: "2"
services:
  rabbit_node_1:
    environment:
      - RABBITMQ_ERLANG_COOKIE='secret_cookie'
    networks:
      - back
    hostname: rabbit_node_1
    image: "rabbitmq:3-management"
    ports:
      - "15672:15672"
      - "5672:5672"
    tty: true
    volumes:
      - rabbit1:/var/lib/rabbitmq
      - ./conf/:/etc/rabbitmq/
    command:  bash -c "sleep 10; rabbitmq-server;"
  rabbit_node_2:
    environment:
      - RABBITMQ_ERLANG_COOKIE='secret_cookie'
    networks:
      - back
    hostname: rabbit_node_2
    depends_on:
      - rabbit_node_1
    image: "rabbitmq:3-management"
    ports:
      - "15673:15672"
      - "5673:5672"
    tty: true
    volumes:
      - rabbit2:/var/lib/rabbitmq
      - ./conf/:/etc/rabbitmq/
    command:  bash -c "sleep 10; rabbitmq-server; "
volumes:
  rabbit1:
    driver: local
  rabbit2:
    driver: local

networks:
  back:
like image 188
Gabriele Santomaggio Avatar answered Sep 20 '22 08:09

Gabriele Santomaggio


Here is simple docker compose

version: "3"

services:

  rabbitmq:
    image: rabbitmq
    command: rabbitmq-server
    expose:
      - 5672
      - 15672
like image 42
Sarath Ak Avatar answered Sep 19 '22 08:09

Sarath Ak