docker-archive / compose-cli

Easily run your Compose application to the cloud with compose-cli
Apache License 2.0
957 stars 254 forks source link

load balancer is of type application, project require a network #1812

Closed jarrah42 closed 3 years ago

jarrah42 commented 3 years ago

Description

I am trying to use an existing application load balancer with my compose script. According to https://docs.docker.com/cloud/ecs-integration, I should be able to create an application load balancer, and then reference it using x-aws-loadbalancer. However, when I try this, docker compose up exits with the message:

load balancer "arn:aws:elasticloadbalancing:us-east-2:NNNNNNNNNN" is of type application, project require a network

Steps to reproduce the issue:

  1. Create application load balancer using the command:
aws elbv2 create-load-balancer --name lb --scheme internet-facing --type application --subnets subnet-aaaa subnet-bbbb subnet-cccc --security-groups sg-mmmm
  1. Use the following docker-compose.yml
version: '3'

x-aws-loadbalancer: arn:aws:elasticloadbalancing:us-east-2:NNNNNNNNNN

services:
    ryp-legacy:
      image: jarrah/ryp:legacy
      build: 
        context: ./legacy/
      networks:
        - ryp-net
    ryp-api:
      image: jarrah/ryp:api
      build: 
        context: ./api/
      volumes:
        - ryp-data:/opt/data
      networks:
        - ryp-net
      depends_on: 
        - ryp-neo4j
    ryp-create:
      image: jarrah/ryp:create
      build: 
        context: ./create/
        args:
          - BASE_HREF=${BASE_HREF:-/ryp}/create/
      networks:
        - ryp-net
      depends_on: 
        - ryp-api
    ryp-chat:
      image: jarrah/ryp:chat
      build: 
        context: ./chat/
        args:
          - BASE_HREF=${BASE_HREF:-/ryp}/chat/
      networks:
        - ryp-net
      depends_on: 
        - ryp-api
    ryp-inspect:
      image: jarrah/ryp:inspect
      build: 
        context: ./inspect/
        args:
          - BASE_HREF=${BASE_HREF:-/ryp}/inspect/
      networks:
        - ryp-net
      depends_on: 
        - ryp-api
    ryp-neo4j: 
      image: neo4j:3.5
      # Remove comments to reach Neo4j GUI from localhost
      ports:
      # HOST_PORT:CONTAINER_PORT
        - "127.0.0.1:7474:7474"
        - "127.0.0.1:7687:7687"
      volumes:
        - ryp-db:/data
      networks:
        - ryp-net      
      environment:
        NEO4J_AUTH: "xxx/yyy"
    ryp-reverse:
      image: jarrah/ryp:reverse
      build:
        context: ./reverse/
      # Unique access point to all components
      ports:
        - 80:80
      networks:
        - ryp-net
      depends_on: 
        - ryp-api
        - ryp-inspect
        - ryp-create
        - ryp-chat
        - ryp-legacy
networks:
  ryp-net:
    driver: bridge

volumes:
  ryp-data:
  ryp-db:
  1. Run docker --context=aws compose up or docker --context=aws compose convert

Describe the results you received:

load balancer "arn:aws:elasticloadbalancing:NNNNNNNNNN" is of type application, project require a network

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Cloud integration: 1.0.14
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.16.3
 Git commit:        370c289
 Built:             Fri Apr  9 22:46:57 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:56 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show:
You can also run docker context inspect context-name to give us more details but don't forget to remove sensitive content.

[
    {
        "Name": "aws",
        "Metadata": {
            "Description": "(us-east-2)",
            "Type": "ecs"
        },
        "Endpoints": {
            "docker": {
                "SkipTLSVerify": false
            },
            "ecs": {
                "Profile": "default"
            }
        },
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": ".docker/contexts/meta/xxx",
            "TLSPath": ".docker/contexts/tls/xxx"
        }
    }
]

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., 2.0.0-beta.1)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 20
  Running: 0
  Paused: 0
  Stopped: 20
 Images: 27
 Server Version: 20.10.6
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.25-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 3
 Total Memory: 3.844GiB
 Name: docker-desktop
 ID: RWRY:LFXE:YOLS:WO35:X7ST:JSCH:V4WV:JIM4:TKDJ:5IBK:BEXJ:Z3NS
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 64
  Goroutines: 49
  System Time: 2021-06-18T00:56:20.3097905Z
  EventsListeners: 4
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS ECS, Azure ACI, local, etc.):

AWS ECS

ndeloof commented 3 years ago

Compose application whith HTTP services only (using ports 80/443 or x-aws-protocol set to http) get an Application Load Balancer created, otherwise a Network Load Balancer is required.

Your application has neo4j service to expose ports 7474 and 7687. If those are actually for HTTP(s) protocol, add an x-aws-protocol element to the port definition to inform ECS integration this one does not require raw TCP routing.

see https://github.com/docker/compose-cli/blob/ebbe86f18da6ae08948659c8545646f65b4c1dc0/docs/ecs-compose-examples.md#load-balancers

jarrah42 commented 3 years ago

Thank you!