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

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

问题描述

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

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"
}

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

but, is it possible to mount specific EBS volume?

F.e.我需要在 Docker 容器中运行 db 并使用 Beanstalk 部署它.很明显,我需要数据的持久性、数据库的备份/恢复等.

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..

推荐答案

您可以在任何 Beanstalk 环境中安装 EBS 卷.此卷将在 EC2 实例上可用.

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

您可以使用 ebextensions 选项设置来做到这一点.在您的应用源文件 .ebextensions/01-ebs.config 中创建一个文件,内容如下:

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

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

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.

此处阅读有关此选项设置的更多详细信息.在此处阅读有关 ebextensions 的更多信息.

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

为 beanstalk 环境实例安装 EBS 卷后,您可以使用上述卷映射根据需要映射目录.

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天全站免登陆