简体   繁体   English

ECS Fargate 额外主机

[英]ECS Fargate Extra Hosts

I am in middle of switching from EC2 to ECS Fargate to host my laravel api and I am using laravel passport oauth function with guzzle to generate access tokens.我正在从 EC2 切换到 ECS Fargate 来托管我的 laravel api,我正在使用 laravel 护照 oauth 功能和 guzzle 来生成访问令牌。 However in order for this to work I have to add an entry to extra_hosts like example.com:10.20.10.140 to my docker-compose.yml.但是,为了使其正常工作,我必须在我的 docker-compose.yml 中向 extra_hosts 添加一个条目,例如 example.com:10.20.10.140。

It looks like I cannot add an extra host entry via Fargate would really appreciate if anyone know of an alternative solution to this problem as the application works perfectly fine on local as well as on ec2.看起来我无法通过 Fargate 添加额外的主机条目,如果有人知道此问题的替代解决方案,我将非常感激,因为该应用程序在本地和 ec2 上都可以正常工作。

Thank you谢谢

The way I worked around similar limitations in the past (eg for me it was searchdomain ) is to add a line in a startup script that hack the local file.我过去解决类似限制的方法(例如对我来说是searchdomain )是在启动脚本中添加一行来破解本地文件。 This is what I did:这就是我所做的:

#!/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

Link to source 链接到源

If you do not want to change the main container/application to do this you can have a sidecar container in the same task that only does this and then exits.如果您不想更改主容器/应用程序来执行此操作,您可以在同一任务中使用一个 sidecar 容器,它只执行此操作然后退出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM