C
C
coderisimo2020-01-29 21:19:09
PHP
coderisimo, 2020-01-29 21:19:09

Is there an easy way to add RabbitMQ to an existing docker project?

For local development I use docker, although I am afraid of it, I wake up at night, scream, but do not give up. Through trial and error, I set up the right environment. Nothing special PHP, MySQL, Mongo, necessary libs in PHP , Nginx. There is a docker-compose, an images directory, it contains a PHP folder with a Dockerfile (it describes any necessary for the normal operation of PHP). mysql and hosts directories.
I would like to try to work with queues and workers. I am learning RabbitMQ. There are no questions about how to use it for simple things, but all attempts to shove STE happiness into the docker are still in vain.
I tried to do a manual using this manual , but to no avail.
Maybe there is an easier way to install this miracle or a step-by-step guide for pensioners?

Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2020-01-30
@coderisimo

In general, here is a config wound up:

version: '2.0'
services:
    rabbitmq:
        image: rabbitmq:3-management-alpine
        container_name: rabbitmq
        volumes:
            - ./.docker/rabbitmq/etc/:/etc/rabbitmq/
            - ./.docker/rabbitmq/data/:/var/lib/rabbitmq/
            - ./.docker/rabbitmq/logs/:/var/log/rabbitmq/
        ports:
            - "5672:5672"
            - "15672:15672"
    nginx:
        image: nginx:latest
        ports:
            - "8000:80"
        # монтируем директории, слева директории на основной машине, справа - куда они монтируются в контейнере
        volumes:
            - ./hosts:/etc/nginx/conf.d
            - ./www:/var/www
            - ./logs:/var/log/nginx
        links:
            - php
    php:
        # у нас свой образ для PHP, указываем путь к нему и говорим что его надо собрать
        build: ./images/php
        links:
            - mysql
            - rabbitmq
        volumes:
            - ./www:/var/www
    mysql:
        image: mariadb
        ports:
            - "3306:3306"
        volumes:
            - ./mysql:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: secret
        environment:
            PMA_HOST: mysql
            MYSQL_USERNAME: root
            MYSQL_ROOT_PASSWORD: secret

Next, we install the plugin, which makes it possible to study what is happening in the rabbit using the browser UI.
To do this, go to the docker container exec -it rabbitmq bash
Install the rabbitmq-plugins enable rabbitmq_management plugin
You can make sure that everything is installed rabbitmq-plugins list
We will be shown a list of installed plugins.
After we go to the address localhost: 15672 (login password, guest by default).
Rabbit is ready! :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question