[英]How to mount file from host to docker container on ECS
I want to mount a file from my host-EC2 to a container which is running on ECS server.我想将一个文件从我的主机 EC2 挂载到一个在 ECS 服务器上运行的容器。 Every change that happens on the file that is on the Host, should be updated on the file in container.主机上的文件上发生的每个更改都应该在容器中的文件上更新。 What I have tried is as follows:我尝试过的内容如下:
Dockerfile: Dockerfile:
FROM nginx
COPY conf/default.conf /etc/nginx/conf.d/default.conf
volume /etc/nginx/conf.d
RUN ln -sf conf/default.conf /etc/nginx/conf.d/
EXPOSE 80
Then pushed the image on ECR Repo and created task, added volume(source path:conf), mountpoint(/etc/nginx/conf.d) and created service to run the container.然后将镜像推送到 ECR Repo 并创建任务,添加卷(源路径:conf)、挂载点(/etc/nginx/conf.d)并创建服务以运行容器。 However every change that I do in the host server, dir: /conf/default.conf does not work on the container /etc/nginx/conf.d/default.conf但是,我在主机服务器中所做的每一项更改, dir: /conf/default.conf 都不适用于容器 /etc/nginx/conf.d/default.conf
I know there is docker run -v but as I'm using ECR, it runs the container itself through the setup.我知道有 docker run -v 但是当我使用 ECR 时,它通过设置运行容器本身。
Any suggestion would be appreciated.任何建议将不胜感激。
Just a suggestion: In you build system, copy the file to S3, and then in your docker container, run a script on startup that copies the latest file back from S3 and mounts it.只是一个建议:在您构建系统中,将文件复制到 S3,然后在您的 docker 容器中,在启动时运行一个脚本,将最新的文件从 S3 复制回来并挂载它。 Then you won't have to rebuild/redeploy your docker container constantly.这样您就不必不断地重建/重新部署您的 docker 容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.