简体   繁体   中英

change ec2 instance to use ecr image and docker

I have ec2 instance for testing. I deployed using OpsWorks, and now I'm making new job on Jenkins to deploy automatically. what I want to do is

when someone push to branch

  1. Jenkins server build docker image
  2. push image to ecr
  3. ec2 instance pull ecr image and build docker container and run

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.

Pre-requisite

On your EC2 you first have to install 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 will do SSH inside EC2 and pull and run the docker image.

  2. Once Jenkin build & push docker image to ECR you can further add the step in Jenkin build steps. Jenkin will trigger shell script file on EC2 . That sh file having all logic to pull the latest one and stop existing etc.

  3. From Jenkins also you can do it via ansible script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM