简体   繁体   中英

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.

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

The below file correctly deploys to the desired vpc, cluster and security group, just not subnet:

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)

This is currently not possible and there is a GitHub issue open to ask for this specifically. 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. It was solved and closed two weeks ago.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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