-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
hostname for container gateway #5651
Comments
Simplest way to do this would likely be to add it to/etc/hosts on
generation - we know the container's IP and gateway at that point.
…On Sun, Mar 29, 2020, 02:30 Mikael Kermorgant ***@***.***> wrote:
/kind feature
*Description*
Provide a dns entry to containers pointing to their gateway.
Context : as a developer, one of my setup involves a service running on
the host machine, that should be proxied by nginx running in a container.
*Describe the results you received:*
I could make it work by writing the container's static gateway ip in
nginx's config.
*Describe the results you expected:*
It would have been nice to have a standard hostname for the gateway (I
believe docker has host.docker.internal for that). Or did I miss some
easy alternative ?
*Output of podman version:*
Version: 1.8.2
RemoteAPI Version: 1
Go Version: go1.14
Git Commit: 028e331
Built: Sat Mar 21 15:30:34 2020
OS/Arch: linux/amd64```
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5651>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3AOCDIELA3CH2ATT2VMTTRJ3TGNANCNFSM4LV3MS4Q>
.
|
A friendly reminder that this issue had no activity for 30 days. |
@ParkerVR PTAL |
I think this is actually already available when using the dnsname plugin. One point, this is NOT purposely enabled on the default network (same with docker). But I think, if i understand your want, it can be done on any network that has the dnsname plugin enabled.
|
Since this is already available, closing. |
I tried to read @baude's answer multiple times to understand how the dnsname plugin solves this problem as I also happen to be in need of this feature, but I'm either failing to understand the answer or there is a misunderstanding. The plugin provides internal hostname resolution for each container on the same network via dnsmasq, which is also visible in In the given example, |
@rhatdan If this needs someone to work on it I'll take a swing at it. |
Go for it. |
Just to make sure I have the details down correctly, when we spin up a container we have the following options for its network configuration
Overall I'm not sure on the technical details required to determine the containers gateway especially in a portable way that will work on windows/mac. Is there anything I should read up on while trying to tackle this ticket / suggestions? Also if any of my assumptions above are wrong please let me know. |
Corrections:
Generally speaking: If |
@mheon Thanks for the insight. I think I have enough to go on now! (hopefully lol) |
Got something working(ish). I am still ironing out the implementation but this might hit the points Matthew outlined That being said according to the CNI spec the I also need to fix the assumed All stuff I still need to figure out 🤷 |
Okay so I think I have an implementation that works but I'm not quite ready for a PR because I'm worried I have some technical details wrong. If someone from Redhat / someone more knowledgeable than me wants to take a look at my changes I would greatly appreciate it. |
I think we'll need @AkihiroSuda or @giuseppe to validate the slirp bits. The CNI bits look fine, though the Slirp and CNI bits should probably be mutually exclusive (I imagine we'll want to use the CNI provided gateway, even in rootless CNI scenarios). |
Yes 👍 |
While messing with tests I had an issue that lead me to an additional potential issue. Currently the code that handles determining the gateway is as follows (getHosts in container_linux_internal.go):
An issue I am worried about is the check that determines if
I don't know if this is possible but if the network status object has multiple results ie len(c.state.NetworkStatus) > 1 , we could end up with multiple Finally @mheon's comment:
I also am not sure how to create this situation to test my implementation. Sorry to ramble here but I am worried my implementation doesn't consider all use cases / my understanding of podman's networking is lacking... |
A friendly reminder that this issue had no activity for 30 days. |
@bblenard @AkihiroSuda @mheon What is going on with this issue? Anything? |
I pushed up some code that might take care of this but when I went to write some unit tests I felt that there could be some issues with my implementation which I mentioned above. I haven't messed with this since though. |
Sorry, didn't see that response. We can potentially end up with multiple CNI results (will happen in any case where a container joins multiple networks), but this is probably OK - we can generate a hosts entry with multiple IP addresses, one for each gateway. |
Okay I can look at picking this backup and try to get a PR opened soon (hopefully within a week or so) Edit: So I double checked
So @mheon can you explain more what you mean when you say
Because I'm interpreting that to mean:
Which seems wrong, but I could be misinterpreting you, the man page, or both |
@mheon bump ^ just in case you didn't see my sneaky edit |
@bblenard No - I believe it is valid to do:
|
Finally got around to opening a PR, its been a while so hopefully I didn't make a silly mistake. I would love some suggestions on how to make sure I test this properly. I did basic sanity checks on my machine
|
A friendly reminder that this issue had no activity for 30 days. |
This issue isn't stale :) still working out the details for the implementation here: #9972 |
This change adds the entry `host.containers.internal` to the `/etc/hosts` file within a new containers filesystem. The ip address is determined by the containers networking configuration and points to the gateway address for the containers networking namespace. Closes containers#5651 Signed-off-by: Baron Lenardson <[email protected]>
Thanks @bblenard for your work on this! |
/kind feature
Description
Provide a dns entry to containers pointing to their gateway.
Context : as a developer, one of my setup involves a service running on the host machine, that should be proxied by nginx running in a container.
Describe the results you received:
I could make it work by writing the container's static gateway ip in nginx's config.
Describe the results you expected:
It would have been nice to have a standard hostname for the gateway (I believe docker has
host.docker.internal
for that). Or did I miss some easy alternative ?Output of
podman version
:The text was updated successfully, but these errors were encountered: