-
Notifications
You must be signed in to change notification settings - Fork 885
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
Fix for certain problems on Synology devices #1068
Conversation
…Ports is not filled
config.ExposedPorts[p] = struct{}{} | ||
// config.ExposedPorts isn't reliably in sync with HostConfig.PortBindings, so we can't assign directly to map without checking | ||
if _, ok := config.ExposedPorts[p]; ok { | ||
config.ExposedPorts[p] = struct{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole point of this code is to empty out map entries, so we should be able to safely skip that action if the map is nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that it is... Couldn't we just assign ExposedPorts to a new map if it's nil instead? If we keep part of the config as nil
we might run into issues in other parts of the code that expects it to be a map.
I think the point of this code is to explicitly add the portbindings to the exposed ports (but with no explicit mapping config), but I may be wrong here.
Since the docker daemon on Synology doesn't return any exposed ports, it's somewhat natural that it doesn't require them in the create container payload. It might break container creation on non-synology docker though...
@@ -298,9 +301,5 @@ func (c Container) VerifyConfiguration() error { | |||
return errorInvalidConfig | |||
} | |||
|
|||
if len(hostConfig.PortBindings) > 0 && containerConfig.ExposedPorts == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Containers get recreated with the correct ports for me, so I'm assuming the Docker client uses the ones it finds in hostConfig.PortBindings
and doesn't necessarily need those from *container.Config.ExposedPorts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we did this instead:
if len(hostConfig.PortBindings) > 0 && containerConfig.ExposedPorts == nil {
containerConfig.ExposedPorts = make(map[Port]struct{})
}
it would just align the docker responses for synology and non-synology docker daemons.
This is essentially what we needed testing. Hopefully this is the only difference on Synology Docker. I don't remember off hand what other images caused the partial config. |
I was thinking, maybe the Dockerfile for |
That seems like the obvious cause, could you do some investigation on this? Like building a docker image with and without EXPOSE and checking Also, the tests fail :) |
Given that we're unable to test this ourselves, we'll have to make due with one pair of eyes on this particular fix. Let me know if you feel it's ready for merging and I'll push it through. |
@tammert Do you have any update on this? I'm experiencing the same issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a suggestion¹ for what would be the least intrusive change to get this working. Just doing this I think is "safe" enough to release in the next version.
¹ It's not a "proper" suggestion though, since github doesn't allow them on deleted rows for some reason...
@@ -298,9 +301,5 @@ func (c Container) VerifyConfiguration() error { | |||
return errorInvalidConfig | |||
} | |||
|
|||
if len(hostConfig.PortBindings) > 0 && containerConfig.ExposedPorts == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we did this instead:
if len(hostConfig.PortBindings) > 0 && containerConfig.ExposedPorts == nil {
containerConfig.ExposedPorts = make(map[Port]struct{})
}
it would just align the docker responses for synology and non-synology docker daemons.
@zoispag - Could you have a look at the review? Thanks! |
@tammert - Could you have a look at this? It would be great if the Container would be able to auto-update using Portainer :) |
This was resolved in #1183. Closing this one |
Avoid 'assignment to entry in nil map' when
*container.Config.ExposedPorts
is not filledThese logs come directly from my Synology device (with the code from this PR running):