【问题标题】:Run docker container with volume argument in AWS ECS as Task definition or Service在 AWS ECS 中将带有卷参数的 docker 容器作为任务定义或服务运行
【发布时间】:2018-11-10 10:02:05
【问题描述】:

我正在使用nginx-proxy docker 映像来代理我的其他 Web 应用程序。 我可以使用

运行此图像
docker run -d -p 80:80 -e ENABLE_IPV6=true -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

命令。如果我在没有-v 的情况下运行 docker,这里-v 选项是强制性的 即

docker run -d -p 80:80 -e ENABLE_IPV6=true jwilder/nginx-proxy

它给出了错误:

ERROR: you need to share your Docker host socket with a volume at /tmp/docker.sock
Typically you should run your jwilder/nginx-proxy with: `-v /var/run/docker.sock:/tmp/docker.sock:ro`
See the documentation at http://git.io/vZaGJ
WARNING: /etc/nginx/dhparam/dhparam.pem was not found. A pre-generated dhparam.pem will be used for now while a new one is being generated in the background.  Once the new dhparam.pem is in place, nginx will be reloaded.

现在我的问题是,当我使用 AWS ECS 任务定义或服务运行此 docker 容器时,如何提供此 -v 参数。

我可以在 Dockerfile 中提供-v 参数吗?

【问题讨论】:

    标签: docker nginx amazon-ecs aws-ecs docker-gen


    【解决方案1】:

    -v 标志是绑定挂载卷的简写。 Here's the AWS documentation for that。您也可以在 AWS 管理控制台中执行此操作,方法是向任务定义修订版添加一个卷,然后在 Storage and Logging 部分的容器定义中,将该卷挂载到容器中。

    AWS Fargate 目前不支持绑定装载。如果您打算使用此 nginx-proxy 设置,您将希望坚持使用 EC2 主机的 ECS。 编辑:这不再正确,Fargate 目前支持绑定挂载(感谢@bobics)

    最后一个警告,绑定挂载的卷只在它们挂载的主机上持续存在。因此,如果您将多个 EC2 实例作为主机运行,您将拥有两个不同的绑定挂载卷。

    【讨论】:

    • 不确定何时更改,但 Fargate 现在支持绑定边界。 docs.aws.amazon.com/AmazonECS/latest/developerguide/… "使用 EC2 或 Fargate 启动类型时支持绑定装载主机卷。"
    • 我在 Fargate 上尝试了绑定挂载,虽然它们可以工作,但看起来它们无法持久化。它不允许我在 volumes -> host 下的任务定义配置中设置 sourcePath 值。
    • Docker 允许在运行时使用 -v 标志挂载卷,但在 ECS 中,我们必须在容器定义期间定义挂载点。如何在runTask 期间指定音量?
    猜你喜欢
    • 2021-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-11
    • 2021-03-07
    • 2019-11-30
    • 2016-04-03
    • 2021-12-24
    相关资源
    最近更新 更多