我是docker的新手,我有一个docker文件,其中包含构建docker映像的所有指令。图像必须部署在AWS Fargate集群中。现在我有了一个python脚本,它可以做以下事情:
1. clone a repo from GitHub
2. Locate the docker file, build the image and push the docker image to AWS ecr
3. Create a task definition and deploy into ECS fargate cluster
4. Additionally the script generate a YAML file based on certain logic that has certain parameters(not related to container config) which is required for the application
在容器开始在AWS中运行之前,我如何使该文件内容可用于容器?我正在检查--entrypoint和--cmd,但在这里我无法更改Dockerfile
有什么方法可以在不更改Dockerfile的情况下实现这一点吗?
如果没有Dockerfile,就无法将层添加到docker映像中。但是,您可以在原始映像之上构建一个新的映像,COPY
处理文件,并保留ENTRYPOINT
CMD
和其他配置。
-
构建";中间体";来自上游Dockerfile的图像,给它一个稍后可以参考的标签:
docker build -t my-intermediate-image:my-version-tag .
-
创建您的yaml文件到
myfile.yml
-
创建一个新的
Dockerfile.final
,启动FROM
中间体:FROM my-intermediate-iamge:my-version-tag COPY myfile.yml /expected/yaml/path
-
使用ECS标签构建最终图像:
docker build -f Dockerfile.final -t accountnumber.ecs.amazonaws.com:my-version .
-
将最终图像标签推送到ECS
-
继续更新ECS任务定义以指向新图像