简体   繁体   中英

How to use multi container docker in Elastic beanstalk using Amazon linux 2?

Currently, Amazon deprecated Multi-container Docker running on 64bit Amazon Linux .Need migrate to Docker running on 64bit Amazon Linux 2 . In 1st version , we used Dockerrun.aws.json v2 to manage multi container docker. In latest version ( Docker running on 64bit Amazon Linux 2 ), we need to use Dockerrun.aws.json v3 or docker-compose . But there is no working example or blogs are available. Can i get working samples ?.

In regards to Elastic Beanstalk and the Docker running on 64bit Amazon Linux 2 platform.

I was struggling too and finally got to the bottom of it. What confused me is that the documentation makes it seem like you can choose to use either, the Dockerrun.aws.json (v3) or a docker-compose.yml in your EB application package.

Then you go looking for the documentation on Dockerrun.aws.json (v3), and you won't find it anywhere.

The reason for this is that, you don't get a choice. If you want to run multiple containers you must include a docker-compose.yml in your application package. The only thing the Dockerrun.aws.json (v3) allows you to do is configure the s3 bucket and key to the location of your container repository authentication file ".dockercfg"

This is essentially the documentation for "Dockerrun.aws.json (v3)" it doesn't support anything similar to the "Dockerrun.aws.json (v2)

{
  "AWSEBDockerrunVersion": "3",
  "Authentication": {
    "bucket": "DOC-EXAMPLE-BUCKET",
    "key": "mydockercfg"
  }
}

Include a docker-compose.yml and you'll need the dockerrun.aws.json (v3) only if the docker images are in a private repository.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/single-container-docker-configuration.html

According to AWS Docs, Multi-container Docker running on Amazon Linux can be migrated to ECS on Amazon Linux 2

This option seems to be easier to apply with the CLI than using the Elastic Beanstalk console because it requires 1 single command:

aws elasticbeanstalk update-environment \
--environment-name ${my-env} \
--solution-stack-name "64bit Amazon Linux 2 ${version} running ECS" \
--region ${my-region}

I'd suggest that you first clone the environment you'd like to upgrade, apply the command mentioned above to this copied environment and test it, if everything works as expected then you can use a blue/green deployment to avoid downtime.

I hope this helps someone!

@Osain This is what the documentation says, but this fails. ECS on Amazon Linux 2 is meant to be a provisioned instance of Amazon ECS Cluster. Before ECS, Elastic Beanstalk was used to deploy containerized Docker containers. However, now with AWS ECS, containers should be deployed using AWS ECS Clusters. To migrate way from the deprecated Multi-Containers on Amazon Linux 1, I used Amazon ECS Clusters with Serverless AWS Fargate to provide the compute instances that can host the containers being deployed (an alternative is to provision in advance the ECS on Amazon Linux 2 by spinning up EC2 instances with this OS). An advantage of using AWS Fargate is that I do not have to provision EC2 instances ahead of time. Scaling up and scaling done is managed by AWS ECS cluster, and implemented by AWS Fargate. (On provisioned EC2, the services may also be auto-scaled but you still have to pay for the running EC2 machines).

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