Standalone xmr with xibo-docker

Is there a way use a single xmr docker container to serve several cms/db containers? I have tried to modify the xmr config of the standard yml-file to forward port 50001 to the docker host IP (i.e. 192.168.110.222:50001)

version: "2.1"

services:
    cms-db:
        image: mysql:5.6
        volumes:
            - "./shared/db:/var/lib/mysql"
        restart: always
        environment:
            - MYSQL_DATABASE=cms
            - MYSQL_USER=cms
            - MYSQL_RANDOM_ROOT_PASSWORD=yes
        mem_limit: 1g
        env_file: config.env
    cms-xmr:
        image: xibosignage/xibo-xmr:release_1.8.2
        ports:
            - "9505:9505"
            - "50001:50001"
        restart: always
        mem_limit: 256m
        env_file: config.env
    cms-web:
        image: xibosignage/xibo-cms:release_1.8.2
        volumes:
            - "./shared/cms/custom:/var/www/cms/custom"
            - "./shared/backup:/var/www/backup"
            - "./shared/cms/web/theme/custom:/var/www/cms/web/theme/custom"
            - "./shared/cms/library:/var/www/cms/library"
            - "./shared/cms/web/userscripts:/var/www/cms/web/userscripts"
        restart: always
        links:
            - cms-db:mysql
            - cms-xmr:50001
        environment:
            - XMR_HOST=cms-xmr
        env_file: config.env
        ports:
            - "80:80"
        mem_limit: 1g

On the other cms I use:

version: "2.1"

services:
    other-cms-db:
        image: mysql:5.6
        volumes:
            - "./shared/db:/var/lib/mysql"
        restart: always
        environment:
            - MYSQL_DATABASE=cms
            - MYSQL_USER=cms
            - MYSQL_RANDOM_ROOT_PASSWORD=yes
        mem_limit: 1g
        env_file: config.env
    other-cms-web:
        image: xibosignage/xibo-cms:release_1.8.2
        volumes:
            - "./shared/cms/custom:/var/www/cms/custom"
            - "./shared/backup:/var/www/backup"
            - "./shared/cms/web/theme/custom:/var/www/cms/web/theme/custom"
            - "./shared/cms/library:/var/www/cms/library"
            - "./shared/cms/web/userscripts:/var/www/cms/web/userscripts"
        restart: always
        links:
            - other-cms-db:mysql
        environment:
            - XMR_HOST=192.168.110.222:50001
        env_file: config.env
        ports:
            - "8081:80"
        mem_limit: 1g

My docker host is debian 9.2 with docker version 17.09.0-ce, build afdb6d4 with IP: 192.168.110.222.

I think I read in another post on here that something like this should work, but there was no further explanation, and I guess I need that :wink: This docker thing is fairly new stuff to me

Any help would be much appreciated. Aslo is there a way to test that I can reach xmr on 192.168.110.222:50001?

You certainly could do it. It’s a bit more involved than your example.

What I’d do is create an XMR only docker-compose file, that joins a pre-created XMR only network. So in /opt/xmr/docker-compose.yml

eg:

version: "2.1"
services:
    cms-xmr:
        image: xibosignage/xibo-xmr:release_1.8.2
        ports:
            - "9505:9505"
        restart: always
        mem_limit: 256m
networks:
    default:
        external:
            name: xmr

Create the xmr network

docker network create xmr

Then bring the XMR container up

cd /opt/xmr
docker-compose up -d

Each of your other CMS instances then go in a separate folder - eg /opt/cms1

Now in your CMS compose files (/opt/cms1/docker-compose.yml), remove the XMR instance completely, and connect the CMS to the XMR network as well:

version: "2.1"

services:
    cms-db:
        image: mysql:5.6
        volumes:
            - "./shared/db:/var/lib/mysql"
        restart: always
        environment:
            - MYSQL_DATABASE=cms
            - MYSQL_USER=cms
            - MYSQL_RANDOM_ROOT_PASSWORD=yes
        mem_limit: 1g
        env_file: config.env
    cms-web:
        image: xibosignage/xibo-cms:release_1.8.2
        networks:
            - default
            - xmr
        volumes:
            - "./shared/cms/custom:/var/www/cms/custom"
            - "./shared/backup:/var/www/backup"
            - "./shared/cms/web/theme/custom:/var/www/cms/web/theme/custom"
            - "./shared/cms/library:/var/www/cms/library"
            - "./shared/cms/web/userscripts:/var/www/cms/web/userscripts"
        restart: always
        links:
            - cms-db:mysql
        environment:
            - XMR_HOST=cms-xmr
        env_file: config.env
        ports:
            - "8081:80"
        mem_limit: 1g

networks:
    xmr:
        external:
            name: xmr

Then the CMS is connected to the same network as the XMR instance is, and will see it simply as cms-xmr.

If you want to add another instance, simply make a new directory, copy the compose file in, and edit the port mapping for the HTTP service.

Better still, use a reverse proxy in front to aggregate them all in to a single port, with different host names.

If you’re just running one or two instances though, I’d just run local XMR instances, as there’s almost 0 overhead in doing so. The only downside will be remembering to change the port number from 9505 to something different in the XMR service port mapping, and in the CMS settings.

Thanks Alex. This looks to be exactly what I want to do

1 Like

When I have it set up like this I get these errors in the xibo logs:

57	afe4227	2017-11-24 23:08	WEB	PUT	ERROR		/display/8	Unable to Process Queue of Player actions due to 1 of 1 player actions failed
56	afe4227	2017-11-24 23:08	WEB	PUT	ERROR		/display/8	Player action connection failed. E = XMR connection failed. Error = Failed to connect the ZMQ: Invalid argument

I use tcp://192.168.110.222:9505, which is the IP of the docker host, as XMR public address, and I’m guessing these errors are related to the public xmr connection. In the xibo client it says it’s connected to xmr and waiting for messages, but it is clearly not working as is.

Any hints as to how I should go about fixing this is much appriciated

Also if anyone else are looking at these examples from Alex, and are as new to docker as me, the line in xmr yml file with “restart: always”(line 7) should only have 8 spaces not 12.

It’s related to the connection to the private port, not the public. I’d have to mock it up here and try it myself.

Presumably you can ping from the CMS container to the XMR container?

docker exec -ti name_of_web_container bash
ping cms-xmr

Ping from cms to xmr works

If ping works then I’d expect XMR to be able to connect.

You definitely put the correct value for XMR_HOST on the web container environment. You didn’t add :50001 or something to it?

What is in the database for that setting?

docker exec -ti name_of_web_container bash
mysql -u cms -p cms
select setting,value from setting where setting like 'XMR%';

That was definitely it.

I’m guessing the mistake I made was to copy my docker-compose.yml file to docker-compose.yml.bak, and then starting the container with: docker-compose up -d

Maybe: docker-compose up -d -f docker-compose.yml would have worked, but I just deleted/moved all files except: config.env docker-compose.yml LICENSE README.md.

For future reference (and for the sake of completion) to check private XMR address I did:
docker ps docker exec -ti [container id] bash mysql -u cms -p[password] use cms select setting,value from setting where setting like 'XMR%';

Thanks for all your valuable help Alex

If you used the commands I gave, it drops you straight in to the correct database, and it will prompt for the password which means it isn’t left in the command history…

docker exec -ti name_of_web_container bash
mysql -u cms -p cms

-p just means the connection needs a password. The final cms is the database name to connect to, not the password for the connection. It will prompt for that.

Yeah sure Alex. I just wanted to post what I did

btw I think I owe you at least a beer for your time and precious help, do you have a donate link somewhere maybe?

If you’d like to send something, then that would be lovely thank you.

You can send funds to info@springsignage.com via Paypal and that will reach us.