Skip to content

Conversation

@dolanor
Copy link
Contributor

@dolanor dolanor commented Jan 2, 2017

Following the discussion on #23 and the patch from @rosscado in #26 (which greatly helped me), I think I fixed the problem watchtower had with restarting a container previously connected to multiple networks.
I can say that It works here ™️ with docker compose.

Hope I'll help other people too.

With insights from moby/moby#29265
the behaviour is the same as the one from docker-compose

* connect to 1 network (at random) at start
* disconnect from that network
* reconnect to all the network from the previous configuration
return err
}

for k, _ := range simpleNetworkConfig.EndpointsConfig {

Choose a reason for hiding this comment

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

should omit 2nd value from range; this loop is equivalent to for k := range ...

dolanor added a commit to dolanor/watchtower that referenced this pull request Jan 14, 2017
@Poeschl
Copy link

Poeschl commented Jan 18, 2017

Any news on this?

@stffabi
Copy link
Contributor

stffabi commented Jan 18, 2017

This will be merged soon. I'm currently refactoring the overall build process. As soon as this is finished, new updated images will be published.

@stffabi stffabi added this to the v0.1.0 milestone Jan 24, 2017
@stffabi
Copy link
Contributor

stffabi commented Jan 24, 2017

Fixes #23

@stffabi stffabi merged commit 0989245 into containrrr:master Jan 24, 2017
@stffabi
Copy link
Contributor

stffabi commented Jan 24, 2017

Thanks @dolanor for your contribution.

log.Debugf("Starting container %s (%s)", name, creation.ID)

return client.api.ContainerStart(bg, creation.ID, types.ContainerStartOptions{})
err = client.api.ContainerStart(bg, creation.ID, types.ContainerStartOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

@dolanor I've just seen that you reattach the networks after the container has already been started. I think it would be better if we first reattach the networks and afterwards start the container again. Or did you have some problems and made it in this order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The explanation of this behaviour is detailed in the git message 😉

f8a2f80

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'm aware of the behaviour that we can't directly create the container with all attached networks. But my question was more if we could do it this way.

  1. ContainerCreate(simpleNetworkConfig)
  2. NetworkDisconnect(simpleNetworkConfig)
  3. NetworkConnect(networkConfig.EndpointsConfig)
  4. ContainerStart()

I think starting the container with only one attached network and afterwards disconnect it and reconnecting the correct ones, may result in strange behaviors for the containers.
It seems like docker-compose also first creates the container, then connects/disconnect the networks and as last step starts the container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see.
Good point. In fact I didn't understand the answer from thaJetzah like that. But you're right.
So I guess my current implementation doesn't work like docker-compose then.
I will fix it tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, that would be great.

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.

4 participants