简体   繁体   English

更改 ec2 实例以使用 ecr 映像和 docker

[英]change ec2 instance to use ecr image and docker

I have ec2 instance for testing.我有 ec2 实例用于测试。 I deployed using OpsWorks, and now I'm making new job on Jenkins to deploy automatically.我使用 OpsWorks 进行部署,现在我正在 Jenkins 上创建新工作以自动部署。 what I want to do is我想做的是

when someone push to branch当有人推动分支时

  1. Jenkins server build docker image Jenkins 服务器构建 docker 镜像
  2. push image to ecr将图像推送到 ecr
  3. ec2 instance pull ecr image and build docker container and run ec2 实例拉取 ecr 镜像并构建 docker 容器并运行

I made a job that using ecr and deploy ECS Fargate, but never done using ecr and deploy pre existed ec2 instance.I wonder this is possible to make it.我做了一份使用 ecr 并部署 ECS Fargate 的工作,但从未使用过 ecr 并部署预先存在的 ec2 实例。我想知道这是否可能实现。

Pre-requisite先决条件

On your EC2 you first have to install docker .在您的EC2您首先必须安装docker

There are many ways you can do it.有很多方法可以做到。

  1. Once Jenkin build & push docker image to ECR you can further add the step in Jenkin build steps.一旦 Jenkin 构建并将 docker 镜像推送到ECR您可以进一步添加 Jenkin 构建步骤中的步骤。 Jenkin will do SSH inside EC2 and pull and run the docker image. Jenkin 将在EC2内执行 SSH 并拉取并运行 docker 镜像。

  2. Once Jenkin build & push docker image to ECR you can further add the step in Jenkin build steps.一旦 Jenkin 构建并将 docker 镜像推送到 ECR,您可以进一步添加 Jenkin 构建步骤中的步骤。 Jenkin will trigger shell script file on EC2 . Jenkin 将在EC2上触发shell script文件。 That sh file having all logic to pull the latest one and stop existing etc.sh文件具有提取最新文件并停止现有等的所有逻辑。

  3. From Jenkins also you can do it via ansible script.从 Jenkins 也可以通过 ansible 脚本来完成。

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

相关问题 EC2 实例策略(配置文件)不允许从 ecr 拉取图像 - EC2 instance policy (profile) not allowing pull image from ecr EC2 CLI泊坞窗中可用的AWS ECR映像 - AWS ECR image available in EC2 CLI docker 从 AWS EC2 上的 AWS ECR 中提取图像而不使用 docker login 但使用 EC2 Instance 角色和 ECR 存储库权限 - Pull images from AWS ECR on AWS EC2 without using docker login but using EC2 Instance role and ECR repository permissions 带有Docker映像的远程更新EC2实例 - Remote update ec2 instance with docker image 将最新镜像从 ECR 部署到 EC2 - Deploy latest image from ECR to EC2 如何让 EC2 实例知道新图像何时推送到 ECR - How to let EC2 instance know when new image pushed to ECR 使用 github 操作将 docker 图像从 ECR 拉到 EC2 时出错 - Error while pulling docker image from ECR to EC2 using github actions 是否可以在不使用 docker 登录的情况下从 EC2 中的 ECR 中提取图像? - Is it possible to pull image from ECR in a EC2 without using docker login? 如果 docker 容器安装在我的 EC2 虚拟机上,我可以在 docker 容器中使用 amazon ecr 凭证助手吗? - Can I use amazon ecr credential helper inside a docker container if its installed on my EC2 VM? 无法远程访问 AWS EC2 实例上的 MySql docker 镜像 - Cannot access remotely MySql docker image on AWS EC2 instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM