简体   繁体   English

如何使用 Elastic Beanstalk 将主机中的文件夹挂载到 Docker 容器?

[英]How can I mount a folder from the host to a Docker container with Elastic Beanstalk?

I have a Dockerfile.aws.json :我有一个Dockerfile.aws.json

{
    "AWSEBDockerrunVersion": "1",
    "Ports": [{
        "ContainerPort": "5000",
        "HostPort": "5000"
    }],
    "Volumes": [{
        "HostDirectory": "/tmp/download/models",
        "ContainerDirectory": "/models"
    }],
    "Logging": "/var/log/nginx"
}

In .ebextensions/download.config , I have:.ebextensions/download.config ,我有:

sources:
  /tmp/download: https://example.com/models.zip

But in my container, /models never gets created.但是在我的容器中, /models永远不会被创建。 What am I doing wrong?我究竟做错了什么?

I tried to replicate the issue, but could not.我试图复制这个问题,但不能。 In my tests the Volumes work as expected.在我的测试中, Volumes按预期工作。

However, you can do some troubleshooting using runlike tool to inspect the command used to actually run your container.但是,您可以使用runlike工具进行一些故障排除,以检查用于实际运行容器的命令。 The tool allow you to check if the EB correctly mounts the volume:该工具允许您检查 EB 是否正确安装了卷:

docker run --name=funny_driscoll --hostname=628fc70a4331 --env=PORT=8080 --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin --volume=/tmp/fffff:/models --expose=8080 --restart=no --detach=true eb14d2391001./testapp docker 运行 --name=funny_driscoll --hostname=628fc70a4331 --env=PORT=8080 --env=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/ sbin:/bin --volume=/tmp/fffff:/models --expose=8080 --restart=no --detach=true eb14d2391001./testapp

To use it, login to the EB instance and install it:要使用它,请登录 EB 实例并安装它:

sudo yum install python-pip

sudo pip install runlike

# check running container
sudo docker ps 

# inspect the docker run command
runlike <container_id>

This will enable to confirm whether the docker run correctly contains --volume= as well as other configuration options.这将能够确认docker run是否正确包含--volume=以及其他配置选项。

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

相关问题 如何将特定日志文件从多容器Docker Elastic Beanstalk流式传输到CloudWatch? - How can I stream a specific log file from multi-container Docker Elastic Beanstalk to CloudWatch? 如何为弹性beanstalk docker容器设置每实例env变量? - How can I set a per-instance env variable for an elastic beanstalk docker container? 如何使用非默认运行参数在AWS Elastic Beanstalk中运行Docker容器? - How can I run a Docker container in AWS Elastic Beanstalk with non-default run parameters? 如何将文件从主机挂载到 ECS 上的 docker 容器 - How to mount file from host to docker container on ECS 如何获得弹性beantalk环境的RDS主机? - How can I get the RDS host of an elastic beanstalk environment? 如何为弹性 beanstalk Windows 应用程序设置文件夹权限? - How can I set folder permissions for elastic beanstalk windows application? Docker nfs4挂载在Elastic Beanstalk上 - Docker nfs4 mount on Elastic Beanstalk Elastic Beanstalk上的节点Docker容器找不到本地Gulp - Node Docker Container On Elastic Beanstalk Can't Find Local Gulp Auth0在Docker容器+ Elastic beanstalk中不起作用 - Auth0 Does not work from inside Docker container + Elastic beanstalk 从docker Elastic Beanstalk容器中获取Elasticache地址 - Get Elasticache address from within a docker Elastic Beanstalk container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM