meDom
meDom

Reputation: 285

Hazelcast failed to connect to Hazelcast-mancenter

I´ve written the following docker-compose.yml to build a running Docker-Instance of Hazelcast with Mancenter.

version: "3"
services:
    hazelcast:
        image: hazelcast/hazelcast:3.12.9
        container_name: hazelcast
        restart: unless-stopped
        environment:
            MAX_HEAP_SIZE: "512m"
            MIN_HEAP_SIZE: "512m"
            JAVA_OPTS: "-Dhazelcast.rest.enabled=true
                        -Dhazelcast.mancenter.enabled=true
                        -Dhazelcast.mancenter.url=http://localhost:8080/hazelcast-mancenter"
        ports:
            - "5701:5701"
        networks:
            - default

    hazelcast-management:
        image: hazelcast/management-center:3.12.9
        container_name: hazelcast-management
        restart: unless-stopped
        ports:
            - "8080:8080"
        networks:
            - default

networks:
  default:
    driver: bridge

The log is always showing the following error, even if I use "127.0.0.1" or my IP instead of localhost. I´m using the same version for both: hc and hc-mancenter.

hazelcast               | Sep 23, 2020 11:38:35 AM com.hazelcast.internal.management.ManagementCenterService
hazelcast               | INFO: [192.168.160.3]:5701 [dev] [3.12.9] Failed to pull tasks from Management Center
hazelcast               | Sep 23, 2020 11:38:35 AM com.hazelcast.internal.management.ManagementCenterService
hazelcast               | INFO: [192.168.160.3]:5701 [dev] [3.12.9] Failed to connect to: http://localhost:8080/hazelcast-mancenter/collector.do

Regards, Dom

Upvotes: 0

Views: 1067

Answers (1)

kgorskowski
kgorskowski

Reputation: 844

Services in docker-compose are on the same "docker network" and reachable via the service name. When you use localhost or 127.0.0.1 the container tries to communicate with its "own" localhost. So instead of Dhazelcast.mancenter.url=http://localhost:8080 you should connect to Dhazelcast.mancenter.url=http://hazelcast-management:8080. The container of the hazelcast service should have a host entry that points the name hazelcast-management to the correct container ip.

Upvotes: 4

Related Questions