[英]AWS Elastic Beanstalk with AMI2 and docker-compose.yml
I have been trying to make Elastic Beanstalk work with Docker AMI2 image and docker-compose.yml
.我一直在尝试使 Elastic Beanstalk 与 Docker AMI2 图像和
docker-compose.yml
。 The documentation says it should work out of the box with docker-compose.yml
file.文档说它应该与
docker-compose.yml
文件一起使用。 I use ECR as docker registry and have updated Elastic Beanstalk role to be able to pull images from ECR.我将 ECR 用作 docker 注册表,并更新了 Elastic Beanstalk 角色,以便能够从 ECR 中提取图像。 https://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/single-container-docker-configuration.html
https://docs.amazonaws.cn/en_us/elasticbeanstalk/latest/dg/single-container-docker-configuration.html
Create a docker-compose.yml file to deploy a Docker image from a hosted repository to Elastic Beanstalk.
创建 docker-compose.yml 文件以将 Docker 映像从托管存储库部署到 Elastic Beanstalk。 No other files are required if all your deployments are sourced from images in public repositories.
如果您的所有部署都来自公共存储库中的图像,则不需要其他文件。 (If your deployment must source an image from a private repository, you need to include additional configuration files for authentication. For more information, see Using images from a private repository.) For more information about the docker-compose.yml file, see Compose file reference on the Docker website.
(如果您的部署必须从私有存储库获取映像,则需要包含其他配置文件以进行身份验证。有关更多信息,请参阅使用来自私有存储库的映像。)有关 docker-compose.yml 文件的更多信息,请参阅撰写文件参考在 Docker 网站上。
However, I keep getting the following message when spinning up the environment:但是,在启动环境时,我不断收到以下消息:
Instance deployment: You must specify a Docker image in either 'Dockerfile' or 'Dockerrun.aws.json' in your source bundle.
实例部署:您必须在源包中的“Dockerfile”或“Dockerrun.aws.json”中指定 Docker 映像。 The deployment failed.
部署失败。
According to documentation Dockerrun.aws.json
should only be required for the old AMI.根据文档
Dockerrun.aws.json
应该只需要旧 AMI。 Has anyone come across similar issue?有没有人遇到过类似的问题?
Found the solution.找到了解决方案。 The documentation states
docker-compose.yml
is the only file needed but it still needs to be zipped before being uploaded to Elastic Beanstalk environment.文档指出
docker-compose.yml
是唯一需要的文件,但在上传到 Elastic Beanstalk 环境之前仍需要对其进行压缩。
I have had some similar issues when migrating to docker-compose file from the dockerrun.json file.从 dockerrun.json 文件迁移到 docker-compose 文件时,我遇到了一些类似的问题。
What I did was to basically create a new app on elastic beanstalk and specify the Amazon Linux 2 platform under Docker as deployement option.我所做的基本上是在弹性 beanstalk 上创建一个新应用程序,并将Docker 下的 Amazon Linux 2 平台指定为部署选项。
Below I will attach my docker-compose.yaml file and also the Github workflow with the part of deploying to ELB if you are interested (Or if it might help someone else)下面我将附上我的 docker-compose.yaml 文件以及 Github 工作流程,如果您有兴趣(或者如果它可能对其他人有帮助)
Docker-compose.yaml, you will need to either remove the image or insert your own image tag url. Docker-compose.yaml,您需要删除图像或插入您自己的图像标签 url。
version: '3'
services:
node-app:
image: <IMG-TAG here e.g from ECR repository>
ports:
- 80:80
github.yaml github.yaml
deploy-staging:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v2
- name: Generate deployment package
run: |
zip -r deploy.zip *
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v9
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: test
environment_name: test
version_label: ${{ github.sha }}
region: eu-north-1
deployment_package: deploy.zip
use_existing_version_if_available: true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.