在AWS beanstalk下将特定的EBS卷装载到Docker [英] Mount specific EBS volume to Docker under AWS beanstalk

查看:258
本文介绍了在AWS beanstalk下将特定的EBS卷装载到Docker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AWS Beanstalk可以从Docker容器运行应用程序。
如文档中所述( http://docs.aws .amazon.com / elasticbeanstalk / latest / dg / create_deploy_docker_image.html )可以将目录映射写入Dockerrun.aws.json中的EC2卷:

 卷:[
{
HostDirectory:/ var / app / mydb,
ContainerDirectory mysql
}

但是,是否可以挂载特定的EBS卷?



Fe我需要在Docker容器中运行db并使用Beanstalk进行部署。很明显,我需要持久的数据,数据库的备份/还原等。

解决方案

你可以挂载EBS任何Beanstalk环境下的卷。该卷将在EC2实例上可用。



您可以使用ebextensions选项设置来执行此操作。在您的应用来源 .ebextensions / 01-ebs.config 中创建一个文件,其中包含以下内容:

 option_settings:
- 命名空间:aws:autoscaling:launchconfiguration
option_name:BlockDeviceMappings
value:/ dev / sdj =:100,/ dev / sdh = snap-51eef269 ,/ dev / sdb = ephemeral0

映射的格式是设备名称=设备映射的卷被指定为单个字符串,并以逗号分隔。此示例将自动缩放组中的所有实例附加到空的100 GB Amazon EBS卷,具有快照ID snap-51eef269的Amazon EBS卷和实例存储卷。



阅读有关此选项设置的更多详细信息此处
详细了解ebextensions here



一旦您为Beanstalk环境实例安装了EBS卷,您可以使用上面的卷映射来根据需要映射目录。


AWS Beanstalk can run applications from Docker containers. As mentioned in the docs (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html) it's possible to write directory mappings to the EC2 volume in the Dockerrun.aws.json:

"Volumes": [
{
  "HostDirectory": "/var/app/mydb",
  "ContainerDirectory": "/etc/mysql"
}

but, is it possible to mount specific EBS volume?

F.e. I need to run db in the Docker container and deploy it with Beanstalk. It's clear that I need to have persistence of the data, backup/restore for db, etc..

解决方案

You can mount EBS volumes on any Beanstalk environment. This volume will be available on the EC2 instances.

You can do this using ebextensions option settings. Create a file in your app source .ebextensions/01-ebs.config with the following contents:

option_settings:
   - namespace: aws:autoscaling:launchconfiguration
     option_name: BlockDeviceMappings
     value: /dev/sdj=:100,/dev/sdh=snap-51eef269,/dev/sdb=ephemeral0

The format of the mapping is device name=volume where the device mappings are specified as a single string with mappings separated by a comma. This example attaches to all instances in the autoscaling group an empty 100-GB Amazon EBS volume, an Amazon EBS volume with the snapshot ID snap-51eef269, and an instance store volume.

Read more details about this option setting here. Read more about ebextensions here.

Once you have mounted the EBS volume for your beanstalk environment instances, you can use the volume mapping as above to map directories per your need.

这篇关于在AWS beanstalk下将特定的EBS卷装载到Docker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆