Add http prefix when docker config detect a insecure registry#39840
Add http prefix when docker config detect a insecure registry#39840baronfel merged 7 commits intodotnet:mainfrom dameng324:main
http prefix when docker config detect a insecure registry#39840Conversation
|
@dotnet-policy-service agree |
|
Separately, this change made a bunch of other tests fail because some of the test systems don't have Docker available - I think if we can't launch Docker we should default to the previous behavior here - the registry should be inferred to be secure-by-default. |
|
This is also relevant to the issue request dotnet/sdk-container-builds#338. |
|
Just curious, would rid potentially lead to unexpectedly getting an image from an insecure registry due to it for some reason not being in the secure registry I expected (or that registry not responding) |
|
That's possible, especially if you didn't fully qualify the image name - e.g.
The SDK, however, currently only expands 'partial' image names into Docker Hub references, so we aren't directly vulnerable to hijacking in that way. |
|
Thanks for your review.
|
|
The work is done. All test passed. please check again @baronfel |
baronfel
left a comment
There was a problem hiding this comment.
I have a question about the conditional, and I'd like another dev on the containers team to check.
|
Ok,Is there anything else you need me to do? |
|
@dameng324 nope, I think this is good to go! Thank you for your work on this feature. I'm going to approve it, but I've also tagged the other SDK Containers feature maintainers so they can give it a look. |
|
/backport to release/8.0.4xx |
|
Started backporting to release/8.0.4xx: https://github.com/dotnet/sdk/actions/runs/9098104332 |
|
Thank you for this excellent contribution @dameng324 - I've started a backport to 8.0.400 so that this will release in August's SDK release. |
As discussed in dotnet/sdk-container-builds#558 (reply in thread)
When add http/https prefix, It will check the local docker config, if found it is an insecure registery, add
httpprefix instead ofhttpsprefix as before.By the way, this pr fix another bug in
DockerCli.GetDockerConfig. If docker daemon is not running, It will throw aDockerLoadExceptioninstead of return a invaild result.I test in my local machine.
daemon.json:
{ "builder": { "gc": { "defaultKeepStorage": "20GB", "enabled": true } }, "experimental": false, "insecure-registries": [ "dockerhub.shengguanda.com" ] }test code:
result: