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

new docker version change ip on container restart #12

Closed
wants to merge 1 commit into from

Conversation

frascuchon
Copy link

Hi,
When service restarts, no ip info it being updated on consul, so change hostname by host ip on service id for service registration.

Best regards

for _, service := range config.Services {
service.Id = fmt.Sprintf("%s-%s", service.Name, hostname)
hostIP := getIp(service.IsPublic)
service.Id = fmt.Sprintf("%s-%s", service.Name, hostIP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the format of the service.Id, replacing the hostname with the hostIP, which breaks expectations elsewhere that this is used.

@frascuchon
Copy link
Author

Hi,

So, when a container is restarted from docker, the service ip in consul should be updated, since this may change.

Thanks !

@tgross
Copy link
Contributor

tgross commented Nov 16, 2015

So, when a container is restarted from docker, the service ip in consul should be updated, since this may change.

@frascuchon I just want to make sure I understand the issue you're seeing here: when a container is stopped and then started elsewhere, its IP address may change. (This doesn't happen when I run docker-machine locally or on Joyent's Triton platform, but I agree that we should assume that there might be a platform where this does happen.) So you're proposing this change so that the IP address is updated in Consul.

In that scenario, the service registration will happen again and any IP address changes will be updated in Consul. I've verified independently that Agent.ServiceRegister will overwrite correctly. This means that, for example, if we have the container app-4fe70bfdef25 running at 172.17.0.20:8000 and it's moved to 172.17.0.21:8000 with the same container ID, Consul will pick up the change.

Am I misunderstanding the scenario you've outlined?

@frascuchon
Copy link
Author

Hi @tgross.

You're right. I test in a local environment with a docker-machine (version 0.4.1) and i can see this behavior

@tgross
Copy link
Contributor

tgross commented Nov 17, 2015

Ok, looks like it's safe to close this then?

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

Successfully merging this pull request may close these issues.

3 participants