I am trying to run a docker container in ECS
, I have already managed to push the Image to ECR
via Jenkins
. I am trying to do the next step which is running the image via Jenkins to ECS.
following is my jenkins file:
node{
stage('SCM Checkout'){
git branch : 'my-branch', credentialsId: 'git-credentials-for-jenkins', url: 'git-url'
}
stage('Build Docker Image'){
sh 'docker build -t my-app:latest ./my-app'
}
stage('Push Docker Image to ECR'){
def file = readFile('./my-app/Version')
def version = file.trim()
docker.withRegistry("XXXXXXXX.amazonaws.com", "aws-credentials"){
docker.image("my-app").push(version)
}
}
stage("Deploy") {
// what to do here ?
}
}
my jenkins instance is on AWS. Any help would be appreciated.
In the case of ECS, docker run
is not enough. You need the following to run container on AWS ECS.
So you can automate the last four-step and better to create the first one manually or also not bad to make this automatic but this one-time creation in the life cycle.
You can check this AWS offical documentation to work with ECS in jenkins.
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.