docker-archive / classicswarm

Swarm Classic: a container clustering system. Not to be confused with Docker Swarm which is at https://github.com/docker/swarmkit
Apache License 2.0
5.75k stars 1.08k forks source link

global mode,link service per node #2808

Closed foxundermoon closed 6 years ago

foxundermoon commented 6 years ago

i am use global mode to deploy my service. the backend-service is backed rest service, the ui is frontend web manager for per service. how to link the ui to backend

version: '3.3'
services:
  backend-service:
    image: 'backend'
    ports:
      - target: 6800
        published: 6800
        protocol: tcp
        mode: host
    deploy:
      mode: global
  ui:
    image: 'ui'
    ports:
      - target: 6801
        published: 6801
        protocol: tcp
        mode: host 
    environment:
      - 'SERVER=http://backend-service:6800'
      - HOST=0.0.0.0
    deploy:
      mode: global
foxundermoon commented 6 years ago

or how to get the node ip inside container?

agalisteo commented 6 years ago

You can use service links, this enable the following environment variables inside ui containers: (assuming your exposed port is 6800)

  ui:
    image: 'ui'
    ports:
      - target: 6801
        published: 6801
        protocol: tcp
        mode: host 
    environment:
      - 'SERVER=http://backend-service:6800'
      - HOST=0.0.0.0
    deploy:
      mode: global
    links:
      - backend-service:backend

more info: https://docs.docker.com/docker-cloud/apps/service-links/#service-link-environment-variables

You can use network strategy too: https://docs.docker.com/engine/swarm/networking/

foxundermoon commented 6 years ago

display Ignoring unsupported options: links when i deploy