[英]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.