container icon indicating copy to clipboard operation
container copied to clipboard

Is it possible to add DNS name resolution for containers?

Open nkpoid opened this issue 1 year ago • 4 comments

It would be great to have DNS name resolution for containers based on their names. For example, if I have a container named hoge, I'd like to be able to resolve its internal IP using something like hoge.container or a similar format. This feature would significantly help with automation and reduce configuration overhead, as we could reference containers by their DNS names rather than hardcoding IP addresses.

nkpoid avatar Jun 10 '25 03:06 nkpoid

I feel like this is addressed in tutorial https://github.com/apple/container/blob/main/docs/tutorial.md#set-up-a-local-dns-domain-optional so yes you can, unless I did not understand the question, and the use case is a bit more complicated than expressed in the question.

outcoldman avatar Jun 10 '25 04:06 outcoldman

Ah, my bad - I didn't properly go through the tutorial. Turns out this feature already does what I need. Thanks! Feel free to close the issue.

nkpoid avatar Jun 10 '25 05:06 nkpoid

Thanks for trying container out!

adityaramani avatar Jun 10 '25 06:06 adityaramani

I had question related with dns thing. Consider this command:

sudo container system dns create test
container system dns default set test
sudo container system dns create cache.test

# resolvable via redis.test, the --dns-domain is not respected
# expected: redis.cache.test
container create --name redis --dns-domain cache.test --dns-option use-vs redis

# resolvable via redis.cache.test, the default domain is not respected
container create --name redis.cache.test redis

Is it expected by design?

fakhrulhilal avatar Oct 03 '25 02:10 fakhrulhilal