0

I have a service which is being accessed from other container, and also from the host itself. definition in docker-compose.yaml

version: "3.8"
services:
  ads:
    image: cloud.dev/ads:test1
    container_name: ads
    hostname: ads
    ports:
      - "9001:9000"

Other containers access this service with ads:9000 while I access from the Host with ads:9001 to that application and it works!

Then I tested docker swarm. I created a stack ams_stack And I defined my ads service for ams_stack

version: "3.8"
services:
  ads:
    image: cloud.dev/ads:test1
    deploy:
      replicas: 1
      placement:
        constraints:
          - "node.role==worker"
    hostname: ams_stack_ads
    ports:
      - "9001:9000"

I see that service is being run!

6b0f8d514f02    cloud.dev/ads:test1   "dssrv_mssql.exe -ad…"   3 hours ago   Up 3 hours    ams_stack_ads.1.owmej7byvzhnwud98dwmo4joe

So I tried to access with:

ams_stack_ads:9001
ams_stack_ads:9000
ads:9001
ads:9000

nothing works... please help...Thanks

vel
  • 1,000
  • 1
  • 13
  • 35
  • What does DNS resolve to for ads on the host? – BMitch May 31 '21 at 13:20
  • Also, please include the errors you receive, rather than saying "nothing works" – BMitch May 31 '21 at 13:21
  • @BMitch I do not have any DNS mapping. For "docker compose" it works out of the box (service is being published immediately to the host machine) while for the "swarm" it does not work because it seems that this service is not being published to be accessed from the host... – vel May 31 '21 at 14:42
  • Your host machine does not know what "ads" means. "localhost:9001" would be the only way to reach the container without a hosts entry or custom dns of some kind. – Chris Becke May 31 '21 at 16:34
  • Do not use docker swarm. It is dead. – Software Engineer May 31 '21 at 16:57
  • @ChrisBecke thanks for useful information. But why does it work like that by default in docker compose? isn't there some information or guidance how I can access my service from the host? – vel May 31 '21 at 22:02
  • @SoftwareEngineer why do you say it is deprecated? ok k8s is alternative but it has also pros and cons – vel May 31 '21 at 22:03
  • No, swarm is dead. It is no longer maintained, despite what Merantis' press releases say. K8s is the industry standard with billions of dollars of research and a massive community - probably the biggest community and installment level of any open standard or software ever. And, swarm was never in competition with k8s - that was Docker Enterprise, which is also dead. If you want something to work, use k8s - it's a million times better anyway. – Software Engineer Jun 01 '21 at 00:05
  • The comments of a question is really not the place to carry out a discussion on how dead, or not swarm in. If Dockercon21 is any indication, many people are still using it in production. To address @AndreyDonald, docker-compose does not do anything to expose service names to the client. "ads:9001" should not work from the browser in either case. – Chris Becke Jun 01 '21 at 06:50
  • @ChrisBecke Chris can you please assist me on this - I cannot access my service with localhost:9001 either from the host. All other docker services can connect to it based on its stack service name. Thank you – vel Jun 02 '21 at 11:28
  • @ChrisBecke I can access my service from the manager node with worker node IP and port 9001. I cannot access from the worker node with worker node IP and Port 9001. Is this regular behavior? Can you please assist – vel Jun 02 '21 at 13:13
  • @ChrisBecke Chris I have created additional question for this strange situation (I can access from the master node and from my lap top and I cannot access from the worker node). Thanks https://stackoverflow.com/questions/67806398/docker-swarm-service-is-accessed-from-the-manager-node-host-only-not-from-the – vel Jun 02 '21 at 14:12

0 Answers0