We have a situation where we would like to start the Django server in normal Elastic Beanstalk mode when connecting the custom Docker container that will be used by the Django website. So far, I basically had the following .ebextensions configuration file:
packages: yum: ecs-init: [] files: /etc/ecs/ecs.config: mode: "000644" owner/group: root content: ECS_CLUSTER=${Ref: MyCluster} commands: 01_start_docker: sudo service docker start 02_start_ecs: sudo start ecs Resources: MyCluster: Type: AWS::ECS::Cluster MyService: Type: AWS::ECS::Service Properties: Cluster: ${Ref: MyCluster} DesiredCount: 1 TaskDefinition: ${Ref: MyTask} MyTask: Type: AWS::ECS::TaskDefinition Properties: ContainerDefinitions: - ...
The problem is that ECS is trying to start before the EC2 instance provided by Elastic Beanstalk is registered in the cluster. As a result, deployment to the elastic beanstalk occurs. If I manually SSH'ed into an EC2 instance and manually installed ecs-init , created ecs.config and executed the commands, the service continues to be created and the EB environment is created successfully.
Is there a way to tell the service to wait for the EC2 instance created by EB autoscale to be registered in the cluster?
More context:
- We want the Django server to be able to access the Docker container with the local host, but I would not mind turning on the EC2 instance in resources specifically designed to host the Docker container, if it is easy to find in autoscaled EC2 instances
- We tried the approach to containers with several dockers, but this method seems closer to using EB (with web server files directly in the environment, instead of portraying dockers to run the environment).
source share