简体   繁体   English

如何将文件从主机挂载到 ECS 上的 docker 容器

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

相关问题 如何使用 Elastic Beanstalk 将主机中的文件夹挂载到 Docker 容器? - How can I mount a folder from the host to a Docker container with Elastic Beanstalk? 我们可以在 AWS ECS docker 容器上挂载 EFS 吗? - Can we mount EFS on AWS ECS docker container? 如何从一个 ECS 容器访问客户端内容到另一个托管 docker 应用程序的 ECS 容器 - How to access client side content from one ECS container to another ECS container where the docker application is hosted 如何将Docker容器映像更新从AWS ECR部署到ECS? - How to deploy docker container image updates from AWS ECR to ECS? 如何在启动(AWS)时将数据从Docker容器复制到ECS? - How to copy data from docker container to ECS on startup (AWS)? 如何将 S3 存储桶挂载到 ecs fargate 容器 - How to mount S3 bucket to ecs fargate container 如何在ECS上自动启动我的docker容器? - How to launch my docker container automatically on ECS? 将文件从Docker容器写入到AWS上的主机实例 - writing file from docker container to host instance on AWS 如何在docker中挂载.pgpass文件? - How to mount .pgpass file in docker? 如何从EC2主机上的AWS ECS容器内访问其他AWS服务? - How to access other AWS services from inside a AWS ECS container on a EC2 host?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM