我怎样才能运行在AWS弹性魔豆泊坞窗容器非默认的运行参数? [英] How can I run a Docker container in AWS Elastic Beanstalk with non-default run parameters?

查看:193
本文介绍了我怎样才能运行在AWS弹性魔豆泊坞窗容器非默认的运行参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个泊坞容器运行伟大在我的本地开发机器。我想移动这 AWS弹性魔豆,但我遇到的麻烦小一点。

I have a Docker container that runs great on my local development machine. I would like to move this to AWS Elastic Beanstalk, but I am running into a small bit of trouble.

我想通过挂载 S3 斗到我的容器 s3fs 。我有Dockerfile:

I am trying to mount an S3 bucket to my container by using s3fs. I have the Dockerfile:

FROM tomcat:7.0
MAINTAINER me@example.com

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential libfuse-dev libcurl4-openssl-dev libxml++2.6-dev libssl-dev mime-support automake libtool wget tar 

# Add the java source
ADD . /path/to/tomcat/webapps/
ADD run_docker.sh /root/run_docker.sh
WORKDIR $CATALINA_HOME

EXPOSE 8080

CMD ["/root/run_docker.sh"]

和我安装 s3fs ,装入 S3 桶,并运行在的Tomcat 图像后,服务器已创建,运行 run_docker.sh

And I install s3fs, mount an S3 bucket, and run the Tomcat server after the image has been created, by running run_docker.sh:

#!/bin/bash
#run_docker.sh

wget https://github.com/s3fs-fuse/s3fs-fuse/archive/master.zip -O /usr/src/master.zip;
cd /usr/src/;
unzip /usr/src/master.zip;
cd /usr/src/s3fs-fuse-master;
autoreconf --install;
CPPFLAGS=-I/usr/include/libxml2/ /usr/src/s3fs-fuse-master/configure;
make;
make install;
cd $CATALINA_HOME;

mkdir /opt/s3-files;
s3fs my-bucket /opt/s3-files;
catalina.sh run

当我建立并且使用命令运行该泊坞容器:

When I build and run this Docker container using the command:

docker run --cap-add mknod --cap-add sys_admin --device=/dev/fuse -p 80:8080 -d username/mycontainer:latest

它工作得很好。然而,当我删除 - 帽子 - 加mknod的--cap相加sys_admin --device =的/ dev /保险丝,然后 s3fs 无法装入我的 S3 桶。

it works well. Yet, when I remove the --cap-add mknod --cap-add sys_admin --device=/dev/fuse, then s3fs fails to mount my S3 bucket.

现在的,我想在运行这个 AWS弹性魔豆,当我部署容器(和运行 run_docker.sh ),所有的步骤执行正常,但步 s3fs我斗的/ opt / S3-文件 run_docker.sh 未安装桶。

Now, I would like to run this on AWS Elastic Beanstalk, and when I deploy the container (and run run_docker.sh), all the steps execute fine, except the step s3fs my-bucket /opt/s3-files in run_docker.sh fails to mount the bucket.

presumably,这是因为无论弹性魔豆不运行泊坞窗的容器,它不添加任何其他标​​志一样, - 帽子 - 加mknod的--cap相加sys_admin - -device =的/ dev /保险丝

Presumably, this is because whatever Elastic Beanstalk does to run a Docker container, it doesn't add any additional flags like, --cap-add mknod --cap-add sys_admin --device=/dev/fuse.

我的 Dockerrun.aws.json 文件看起来像:

{
  "AWSEBDockerrunVersion": "1",
  "Image": {
    "Name": "tomcat:7.0"
  },
  "Ports": [
    {
      "ContainerPort": "8080"
    }
  ]
}

是否有可能增加其他泊坞窗运行标记到AWS EB泊坞部署? 另一种选择是找到另一种方式挂载 S3 斗,但我怀疑我会碰到类似的权限错误不管。有没有人看到任何方式来完成这项???

Is it possible to add additional docker run flags to an AWS EB Docker deployment? An alternative option is to find another way to mount an S3 bucket, but I suspect I'd run into similar permission errors regardless. Has anyone seen any way to accomplish this???

更新:

有关人们试图用@低于叶戈尔的回答,它的工作原理,当EB配置设置为使用 V1.4.0运行泊坞1.6.0 。任何过去的V1.4.0版本失败。因此,为了使其工作,建立自己的环境为正常(这应该给你一个失败的版本),然后用 V1.4.0运行泊坞1.6.0 配置重建。这应该这样做!

For people trying to use @Egor's answer below, it works when the EB configuration is set to use v1.4.0 running Docker 1.6.0. Anything past the v1.4.0 version fails. So to make it work, build your environment as normal (which should give you a failed build), then rebuild it with a v1.4.0 running Docker 1.6.0 configuration. That should do it!

推荐答案

添加文件 .ebextensions / 01-commands.config

container_commands:
    00001-docker-privileged: command: 'sed -i "s/docker run -d/docker run --privileged -d/" /opt/elasticbeanstalk/hooks/appdeploy/pre/04run.sh'

我也使用s3fs

这篇关于我怎样才能运行在AWS弹性魔豆泊坞窗容器非默认的运行参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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