[英]Multi-Container Docker on AWS
I've can't seem to get my head around the Dockerrun.aws.json file, which is needed to run a multi-container docker environment on AWS Elastic Beanstalk.我似乎无法理解 Dockerrun.aws.json 文件,这是在 AWS Elastic Beanstalk 上运行多容器 docker 环境所必需的。
Everything works fine locally, when I run my app through Docker-Compose. The following is my docker-compose.yml file:当我通过 Docker-Compose 运行我的应用程序时,在本地一切正常。以下是我的 docker-compose.yml 文件:
version: '2'
services:
interfaceserver:
build: .
command: daphne -b 0.0.0.0 -p 8000 restbench.asgi:channel_layer
user: app
working_dir: /app
ports:
- 8000:8000
depends_on:
- database
- redis
workerserver:
build: .
user: app
working_dir: /app
command: python manage.py runworker
depends_on:
- database
- redis
database:
image: postgres:9.5
redis:
image: redis:3.0-alpine
Essentially I am trying to run four services.本质上我正在尝试运行四个服务。 A Interface-Server, a Worker-Server, a Postgres Database and a Redis Server.
一个接口服务器、一个工作服务器、一个 Postgres 数据库和一个 Redis 服务器。 The Interface-Server and the Worker-Server and my own Django Builds from a local Dockerfile which are in the same directory as the docker-compose.yml
Interface-Server 和 Worker-Server 以及我自己的 Django 从本地 Dockerfile 构建,它们与 docker-compose.yml 在同一目录中
Now I am trying to deploy my app to Elastic Beanstalk and, from what I understand, I need a Dockerrun.aws.json, which is the same as a docker-compose.yml, just for AWS.现在我正在尝试将我的应用程序部署到 Elastic Beanstalk,据我所知,我需要一个 Dockerrun.aws.json,它与 docker-compose.yml 相同,仅适用于 AWS。 I try to read the docs from EBS, but as I mentioned above I can't get my head around the part where I specify the Interface- and Worker-Server.
我尝试阅读 EBS 的文档,但正如我上面提到的,我无法理解指定接口和工作服务器的部分。 The Database and Redis part is easy, but I don't understand how to specify how to build these two servers in the json file for AWS.
数据库和 Redis 部分很简单,但我不明白如何在 AWS 的 json 文件中指定如何构建这两个服务器。
Any help is highly appreciated.非常感谢任何帮助。
We can't build images from Dockerfile anymore in "AWSEBDockerrunVersion: 2". 我们不再可以在“ AWSEBDockerrunVersion:2”中从Dockerfile构建映像。 It is possible if we have a single container setup with single Dockerfile by using "AWSEBDockerrunVersion: 1".
通过使用“ AWSEBDockerrunVersion:1”,可以使用单个Dockerfile进行单个容器设置。
In your case, you have to build & push images by your own or let your CI server do it. 在您的情况下,您必须自己构建并推送图像,或者让CI服务器来完成。 Define the images in your Dockerrun.aws.json v2.
在Dockerrun.aws.json v2中定义图像。
Ref from AWS docs - 来自AWS文档的参考-
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html#create_deploy_docker_v2config_dockerrun http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html#create_deploy_docker_v2config_dockerrun
Docker Images - The Multicontainer Docker platform for Elastic Beanstalk requires images to be prebuilt and stored in a public or private online image repository. Docker映像 -用于Elastic Beanstalk的Multicontainer Docker平台需要预先构建映像并将其存储在公共或私有在线映像存储库中。 Building custom images during deployment with a Dockerfile is not supported by the multicontainer Docker platform on Elastic Beanstalk.
Elastic Beanstalk上的多容器Docker平台不支持使用Dockerfile部署期间构建自定义映像。 Build your images and deploy them to an online repository before creating an Elastic Beanstalk environment.
在创建Elastic Beanstalk环境之前,请构建您的映像并将其部署到在线存储库。
According to the docs , Amazon Linux 2 now supports docker-compose files and doesn't have the limitation of needing prebuilt images for Multi-Container Docker environments anymore.根据文档,Amazon Linux 2 现在支持 docker-compose 个文件,不再需要为多容器 Docker 环境预构建图像的限制。
The Multi-container Docker platform on Amazon Linux AMI requires that you specify prebuilt application images to run as containers.
Amazon Linux AMI 上的多容器 Docker 平台要求您指定预构建的应用程序映像作为容器运行。 After migrating, you will no longer have this limitation, because the Amazon Linux 2 Docker platform also allows Elastic Beanstalk to build your container images during deployment.
迁移后,您将不再有此限制,因为 Amazon Linux 2 Docker 平台还允许 Elastic Beanstalk 在部署期间构建您的容器镜像。
... ...
The Docker Compose tool uses the docker-compose.yml file for configuration of your application services.
Docker Compose 工具使用 docker-compose.yml 文件来配置您的应用程序服务。 This file replaces your Dockerrun.aws.json v2 file in your application project directory and application source bundle.
此文件替换应用程序项目目录和应用程序源包中的 Dockerrun.aws.json v2 文件。
We haven't migrated our environments yet, but that sounds promising.我们还没有迁移我们的环境,但这听起来很有希望。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.