amazon-ecraws-batch

Can I choose a specific ECR docker image revision to use with AWS Batch?


This is a repeat of this earlier question Using AWS Batch can a docker image be specified dynamically in a job definition?

I'm asking again since it's been 5 years since the original question, and I'm hoping for some developments in this space.

Essentially, my end goal is to be able to support multiple versions of an image that can be specified at runtime when I kick off a set of jobs in AWS Batch. E.g. Project A uses image version 1.0.2, but Project B uses image 2.1.3

Currently I only know how to have both Projects A and B use the :latest docker image, which makes it more difficult to develop and maintain backwards compatibility when there are multiple projects occurring at the same time.


Solution

  • The AWS Batch SubmitJob API call does not allow over-riding the image of the Job Definition in the containerOverrides parameter. This is due to ECS also not allowing a Task to override the container image when the Task is run.

    You could have this by defining multiple versions of a Job Definition with different image versions, but honestly that will land you in hot water one day. It is better to just name job definitions with the specific container image version.

    Note that for EKS, AWS Batch SubmitJob does allow overriding the image in the pod spec, since this is something that Kubernetes itself allows.