Reputation: 1381
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.
Upvotes: 1
Views: 1820
Reputation: 60114
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.
devops/set-up-a-build-pipeline-with-jenkins-and-amazon-ecs
Upvotes: 2