简体   繁体   English

AWS Elastic Beanstalk上的Docker中的Docker

[英]Docker in docker on AWS Elastic Beanstalk

I have a docker container running on elastic beanstalk. 我有一个在弹性beantalk上运行的docker容器。 From within this container I want to run other containers using the docker daemon running on the host OS. 从这个容器中,我想使用在主机OS上运行的docker守护程序运行其他容器。

As I read here http://blog.docker.com/category/demos/ , it is possible if the first container is invoked by: 当我在这里阅读http://blog.docker.com/category/demos/时 ,第一个容器可能由以下方式调用:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock <image_name>

Can I make Beanstalk invoke my container is such way? 我可以这样使Beanstalk调用我的容器吗?

Unfortunately, Amazon Elastic Beanstalk adopts the policy " one container per VM ", which is fairly limiting. 不幸的是,Amazon Elastic Beanstalk采用了“ 每个虚拟机一个容器 ”的策略,这是相当有限的。

There might be a workaround, but it will be a waste of time. 可能有解决方法,但这会浪费时间。

You shoud use Amazon EC2 if you need to do that. 如果需要,您应该使用Amazon EC2。

You can set up a new instance running Docker in less than 5 minutes! 您可以在不到5分钟的时间内设置一个运行Docker的新实例!

Yes, its possible, but YMMV. 是的,可能,但是YMMV。 Here's a rundown: 这是一个摘要:

Dockerrun.aws.json allows you to map arbitrary paths into your container path. Dockerrun.aws.json允许您将任意路径映射到您的容器路径。 So, you can map your hosts's /var/run (which contains docker.sock ) into a temp path. 因此,您可以将主机的/var/run (包含docker.sockdocker.sock到临时路径。 Here are the steps: 步骤如下:

Make sure you've got a staging directory 确保您具有暂存目录

In your dockerfile: 在您的dockerfile中:

RUN mkdir /run-data

Make sure Dockerrun.aws.json contains it: 确保Dockerrun.aws.json包含它:

{
    "AWSEBDockerrunVersion": "1",
    "Logging": "/app/log",
    "Volumes": [
        {
            "HostDirectory": "/var/run",
            "ContainerDirectory": "/run-data"
        }
    ]
}

Then, the /run-data/docker.sock will contain a suitable docker socket for running commands. 然后,/ /run-data/docker.sock将包含一个适合运行命令的/run-data/docker.sock套接字。 From this point, you can refer to the docker api and talk to it directly 至此,您可以参考docker API并直接进行交谈

Happy docking! 对接快乐!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM