-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Pass through port binding dict #135
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
Conversation
Could you fix the style error and squash these two commits together? Thanks! |
I'm not too happy about having 2 ways to use ports. Am I the only one? I think we broke backwards compatibility with that feature on purpose as to have a more Pythonic API. |
@mpetazzoni Sure, no problem, but can you elaborate on the style error? Also, going to ensure this is the right direction first. @denibertovic If this was done intentionally, then no problem. I just went to the README and see that the format is well-documented, so my fault for not reading! :) I agree with having one known way of doing things; close at your leisure. |
Actually, what if the else statement is changed so that it will fail if the binding param is not a string or int. A dict should not be stringified and used as the port; I spent a good amount of time figuring out why my port bindings stopped working. |
Personally I don't like doing defensive coding like that in a dynamic language. If one passes incorrect parameters the API will tell us. But maybe @mpetazzoni and @shin- can weigh in. |
Is silently doing the wrong thing better? I realize that the library is under heavy dev, so backwards incompatible changes are to be expected (and the docs clearly describe the parameter format), but just to illustrate, I ended up with a stringified dict as the Anyway, not trying to be a pain here, just describing the issue I ran into. Thanks! |
@denibertovic What are your thoughts on something like this? I suppose you'd still consider this defensive coding, but do we agree that |
Yes we agree that we should not let wrong values just fly like that, i'm just trying to limit the number of times we need to do stuff with type and isistance :) I think it's maybe worth looking into why the API didn't raise an error if it got malformed values from the client. This does seem better, although this can also raise a ValueError (ie int('some string')) not just a TypeError. Can you paste the example that you used that produced the initial error. What got sent to the API (and the result was a random port assigned right?) |
Ensure the HostPort value is numeric just in case a bogus port binding was passed in.
Yes, it can raise a Here's the binding that brought us here today. Feed this into {'HostPort': '49159', 'HostIp': '0.0.0.0'} And get this back:
|
@denibertovic And to answer your question, yes, port randomly assigned and IP ignored. |
@shin- what do you tnink? |
Not too sure about this, let me play with it a bit first! Ideally, if we can accomodate both ways of doing things (i.e. passing arguments in the official CLI format + passing arguments in the python friendly format) I'd like us to do that. |
Unfortunately I've been force updating but the initial patch checked to see I can resurrect the patch, but it will be Monday before I can do so. Let me know. On Friday, January 10, 2014, Joffrey F wrote:
|
Upon upgrading docker and docker-py my code stopped working because I was passing the port bindings as a properly formatted list of dict objects. This patch re-allows passing the ports in the already-correct format.
Please let me know if this is a good fix and/or if it needs some tweaks.
Thanks!