Vignesh_A
Vignesh_A

Reputation: 548

Docker swarm container replicas are running but not able to hit the same in browser or with curl

Am following docker documentation and trying to create replica of nodes using the link --> https://docs.docker.com/get-started/part3/

I have followed the steps as mentioned in the document but am not able to get the expected application response on curl or browser.

docker decompose file looks like below :

version: "3"
services:
  web:
    image: vigneshnithin23/restaurant:latest
    deploy:
      replicas: 2
      placement:
          constraints: [node.role == manager]
      resources:
        limits:
          cpus: "0.1"
          memory: 50M
      restart_policy:
        condition: on-failure
    ports:
      - "8090:8090"
    networks:
      - webnet
networks:
  webnet:

As per the documentation they are able to curl the URL. whereas am not able to do the same.

I had two IP address and initialised docker swarm with --advertise-addr - First wlan address

if I run the same code on single container am able to get the desired result.

I went through the question in below link, which was asked earlier but that didn't have proper answer

Website available in standalone container, not in swarm

Any help would be appreciated.

Upvotes: 2

Views: 363

Answers (1)

Sujay Pillai
Sujay Pillai

Reputation: 433

You need to ask yourself whether your SpringBoot app would be able to run in that constrained environment of 50% usage of the CPU per second and 50M.

When you run that as a single container[9ms for startup] it is running in a non-constrained environment while in your stack file you are restricting it. So when you spin up the service it takes a longer time to warm up and get started.

Here is a screenshot of the same app by just changing the replica set to '1' and increasing the memory to 100M it takes around 900ms to serve the application & serve the response. enter image description here

So try to fine tune those settings for resource constraints.

Upvotes: 1

Related Questions