简体   繁体   English

如何使 docker 组合使用现有的 AWS 子网

[英]How to make docker compose use existing AWS subnet

I have created an AWS VPC, subnet and security group and want to deploy my docker containers to these premade resources as a fargate ecs service.我已经创建了一个 AWS VPC、子网和安全组,并希望将我的 docker 容器作为 fargate ecs 服务部署到这些预制资源。

However I don't know how to tell the service to use a premade subnet (it looks like it randomly picks a subnet from an 'allowed' list of subnets which is currently all subnets I have in my VPC但是我不知道如何告诉服务使用预制子网(看起来它从“允许”子网列表中随机选择一个子网,该列表目前是我在我的 VPC 中拥有的所有子网

The below file correctly deploys to the desired vpc, cluster and security group, just not subnet:以下文件正确部署到所需的 vpc、集群和安全组,而不是子网:

version: '2'

x-aws-cluster: "Test Cluster"
x-aws-vpc: "vpc-02dffc2a8782579d4"
x-aws-security-group: "sg-02511658ffc184884"

services:
    nginx:
        image: nginx:1.19
        networks:
            - Backend-Access

networks:
    Backend-Access:
        external:
            name: sg-02511658ffc184884
        ipam:
            driver: default
            config:
            - subnet: subnet-0aeef680f1f9e5cda # this has no effect
            #- subnet: 172.31.4.0/24 also does not place the service in this subnet

I am running it using docker compose up -d (running it without -d gives a cluster does not exist error)我正在使用docker compose up -d运行它(在没有 -d 的情况下运行它会给出集群不存在错误)

This is currently not possible and there is a GitHub issue open to ask for this specifically.目前这是不可能的,并且有一个GitHub 问题可以专门询问这个问题。 If you could made your voice be heard there that's where we are consolidating this feedback.如果您可以在那里听到您的声音,那么这就是我们整合这些反馈的地方。 Thank you.谢谢你。

It is possible to make a subnet using the documented overlay method now and I solved it.现在可以使用记录的覆盖方法制作子网,我解决了它。

See the Github issue again.再次查看Github 问题 It was solved and closed two weeks ago.两周前解决并关闭。

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

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