gpt4 book ai didi

amazon-web-services - 为什么使用 `awsvpc` 网络模式的 ECS 容器无法在 CloudFormation 中声明 `extraHosts`?

转载 作者:行者123 更新时间:2023-12-03 07:22:51 26 4
gpt4 key购买 nike

我希望能够使用 extraHosts 为 CloudFormation 中的 docker 容器声明其他主机指示。不幸的是,由于我使用的是 Fargate,这是不可能的,因为 Fargate 始终使用 awsvpc 网络模式。

为什么在 awsvpc 模式下无法在容器的主机文件中声明额外条目?这不只是一个简单的额外调用--add-host在幕后吗?

最佳答案

AWSVPC 模式是一种自定义模型,不使用基于标准容器的 docker 标志。换句话说,它们需要在“任务”级别重新实现(可用于任务内的所有容器),而我们只是尚未实现此标志(以及 searchDomains 等其他标志)。

在我的一个业余项目中,我通过使用读取变量并配置容器本身的脚本启动容器来解决这个问题。该文件是here为了方便起见,我将其复制/粘贴到此处:

#!/bin/bash

# when the variable is populated a search domain entry is added to resolv.conf at startup
# this is needed for the ECS service discovery given the app works by calling host names and not FQDNs
# a search domain can't be added to the container when using the awsvpc mode
# and the awsvpc mode is needed for A records (bridge only supports SRV records)
if [ $SEARCH_DOMAIN ]; then echo "search ${SEARCH_DOMAIN}" >> /etc/resolv.conf; fi

ruby /app/yelb-appserver.rb -o 0.0.0.0)

GH issue 中有关于该主题的其他讨论.

关于amazon-web-services - 为什么使用 `awsvpc` 网络模式的 ECS 容器无法在 CloudFormation 中声明 `extraHosts`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70658976/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com