aws-sam-cli
aws-sam-cli copied to clipboard
Custom DNS support for SAM Docker container
Problem: A non-trivial local dev environment may consist of a number of docker containers with highly customized network settings. SAM local doesn't seem to support the desired level of network customization at the moment, thus hinders interoperability between SAM local and other container dependencies.
Example:
We use dnsmasq as a custom DNS resolver for other containers by passing --dns
in docker run. This setting doesn't seem to be supported by sam cli, so we had to hack this kwargs to supply the dns resolver's IP.
Discussion:
Is there a plan to support more Docker network settings via sam local
flags? Or it's something to be added one by one on demand (like this one)? I can imagine these kinds of requirements might come in more often in the future. So I wonder if a more generic mechanism to customize Docker settings can be designed and implemented in the future.
I'm fairly new to 🐿, so please do let me know if I missed anything obvious. Thanks!
@taoza Thanks for submitting this! I find this use-case interesting. Can you explain further on needing to use this different DNS resolver? Is this something you also do in Lambda to interact with other services? I am trying to understand the use-case clearly so I can map SAM CLI's use-case directly to AWS Lambda.
Generally, we are open to supporting more Docker settings in general. We have an open PR for a .samrc (#689), which seems like it could be a good vehicle for supporting certain settings and not requiring command line flags for everything.
@jfuss We have a Docker based dev environment that relies on a local dnsmasq (also containerized) for DNS lookup. This is achieved by providing all containers in this environment with a --dns
flag. When requests are made from SAM container, in order to use the consistent hostname and resolve through dysmasq, we would have to provide the dns flag too.
.samrc does feel like a good place to customise certain Docker settings. I wonder if you would make a dedicated Docker run section with transparent params, or the settings would be cherry-picked to support.
Any update on this feature? My team would also like something like the ability to set the --dns
. It seems as @taoza has pointed out that there is already a parameter inside of the Container
class to sent the --dns
config to. It seems just a matter of exposing this as a command line argument or inside of the .samrc
. How open is the team to receiving pull-requests for a feature like this?
Thanks for the interest. We are currently going through older issues to see what is still relevant. We are electing to closing this as we want local to be as close to the cloud as we can. If there is still interest from this, please create a new issue and we can have a deeper discussion.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.