Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot connect to server in Docker #104

Closed
tempura-shrimp opened this issue Jun 23, 2016 · 3 comments
Closed

Cannot connect to server in Docker #104

tempura-shrimp opened this issue Jun 23, 2016 · 3 comments

Comments

@tempura-shrimp
Copy link

tempura-shrimp commented Jun 23, 2016

Hi,

Thank you for writing such amazing framework. However, I encountered a problem when I deploying my program: If a deploy my program in docker, other micro-based program (even micro cli outside docker) cannot access the program.

I looked into the problem, figured out that the problem come from "ServiceAddress" key in register, whose value is an internal IP inside of docker which impossible to be accessed from any remote environment.

registry have following value

{  
   "Node":"b75b88eb2e1a",
   "Address":"192.168.100.17",
   "ServiceID":"tech.ngs.sms-a4d6a869-38fc-11e6-895d-0242ac110002",
   "ServiceName":"tech.ngs.sms",
   "ServiceTags":[  
      "t-789caa562a294acc2b2ec82f2a51b252ca28292950aa05040000ffff4f930768",
      "t-789caa564a2acacf4e2d52b252ca28292950aa05040000ffff364d0600",
      "t-789caa562a4e2d2a4b2d52b2522a2a4856aa05040000ffff30dd0597",
      "t-789caa562a4a4dcf2c2e29aa54b2524acecf2b2ecd51aa05040000ffff560f07c8",
      "e-789c9492b14ec3400c86dfe5e68801b6ac1421862e3d850531b889a92c39be625f2a219477c7112569a920e916399f2d7ffeef3308b418ca10d731a21ea846bb8928cd230a2ad55e0e45507cefd07228477cfafd0c4c0d644ab2395245c81ffb79e800ec5fa17c198756865a554fab69826525d99dc0d231f7c5d8b14e5b625ccedfa766967eed0761db27313c31768bcd4f759c705ebc348a5ded07b5a9619b12ffbdde836ad2e536c75b2e919a9a626bbe72c7f9b7c577e9d2e17c3c49bebbfd2710b785dd15ebac3003f17c26432aadb3fe8a6048c53984d61bde80fdf87dff150000ffffa6acf21e",
      "e-789c9451b14ec3400cfd17cf11036c5981314b6f440c6e63a2939cbb72f65542e8fe1d07a24b4a15b5ddace7f79edeb3bf21e048d082eb9ca374f207920747a1dfd1e04529190e0d24facc240a6de5aff6bb79d9807e1d377727649ba07dab165ddc7ba645269a7c1856d490994b53f9cfb1bfca7e2f535839c620b44afb9b6446abc3397899cfe5835d4316c13e46de8ef79a524cb7b7992f734ba945e446b1c899f57f8b3fe8b2c3b9bd0ffaf4b8edde595b1cee88f3428a9eafff64faca68dc1e15a7af188f7034c107b21dbf949f000000ffff0948db07",
      "v-789c32d43300040000ffff01220090"
   ],
   "ServiceAddress":"172.17.0.2",
   "ServicePort":10000,
   "ServiceEnableTagOverride":false,
   "CreateIndex":4003,
   "ModifyIndex":4003
}

I implemented following code to init the service

b := broker.NewBroker(
        broker.Addrs(":10001"),
    )

    srv := server.NewServer(
        server.Name(SERVICE_NAME),
        server.Address(":10000"),
        server.Broker(b),
    )

    service := micro.NewService(
        micro.Server(srv),

Thanks

@asim
Copy link
Member

asim commented Jun 23, 2016

The server uses the address its bound to for registration. If you want to change that you can specify a different server address. If you want it to bind to that address but advertise something different you can use the server.Advertise option

// The address to advertise for discovery - host:port
func Advertise(a string) Option {
    return func(o *Options) {
        o.Advertise = a
    }
}

@asim
Copy link
Member

asim commented Jun 23, 2016

Also note there's an API gateway for accessing services externally and the Sidecar can be used as a proxy for the CLI by specifying --proxy_address

Info on both here https://github.com/micro/micro/tree/master/api and https://github.com/micro/micro/tree/master/car.

@asim
Copy link
Member

asim commented Jun 24, 2016

Please update with a comment otherwise the issue will be closed.

@asim asim closed this as completed Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants