Is it possible to directly call docker run from AWS lambda

I have a Java standalone application which I have dockerized. I want to run this docker everytime an object is put into S3 storage. On way is to do it via AWS batch which I am trying to avoid.

Is there a direct and easy way to call docker run from a lambda?

  • How to use t2.nano ec2 instances in an Amazon ec2 container cluster?
  • Container delivery on amazon ecs
  • Upload to s3 from docker container running inside ECS not working
  • Consul agent are still marked as in critical state after terminating whole instance
  • Trouble getting AWS ecs-cli to pull from private docker repo
  • How to access private Docker repository in OpsWorks ECS Layer?
  • AWS ECR Authentication Test
  • port number not accessible when running webpack-dev-server
  • Making a directory inside a Docker container accessible from another container
  • Amazon ECS support for --shm-size in docker
  • Logs to AWS Cloudwatch from Docker Containers
  • Running a Docker container on AWS Elastic Beanstalk - Where is my web app?
  • One Solution collect form web for “Is it possible to directly call docker run from AWS lambda”

    Yes and no.

    What you can’t do is execute docker run to run a container within the context of the Lambda call. But you can trigger a task on ECS to be executed. For this to work, you need to have a cluster set up on ECS, which means you need to pay for at least one EC2 instance. Because of that, it might be better to not use Docker, but I know too little about your application to judge that.

    There are a lot of articles out there how to connect S3, Lambda and ECS. Here is a pretty in-depth article by Amazon that you might be interested in:

    If you are looking for code, this repository implements what is discussed in the above article:

    Here is a snippet we use in our Lambda function (Python) to run a Docker container from Lambda:

    result = boto3.client('ecs').run_task(

    We pass in the name of the cluster on which we want to run the container, as well as the task definition that defines which container to run, the resources it needs and so on. overrides is a dictionary/map with settings that you want to override in the task definition, which we use to specify the command we want to run (i.e. the argument to docker run). This enables us to use the same Lambda function to run a lot of different jobs on ECS.

    Hope that points you in the right direction.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.