AWS ElasticBeanstalk can't find Dockerfile
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When Elastic Beanstalk says it cannot find your Dockerfile, the problem is usually not Docker itself. It is usually one of three things: the file is not at the top level of the source bundle, the chosen Elastic Beanstalk Docker platform expects a different configuration file, or the application was zipped from the wrong directory.
Start with the Platform Branch
Elastic Beanstalk Docker support is not one single mode. According to the AWS documentation, different platform branches expect different top-level files.
Important cases:
- single-container Docker on Elastic Beanstalk can use a
Dockerfile - Docker Compose based environments use
docker-compose.yml - ECS-managed Docker branches expect prebuilt images and
Dockerrun.aws.jsonrather than building from a localDockerfile
That means the first debugging question is not “where is my Dockerfile,” but “does this platform branch even build from one?”
The Dockerfile Must Be at the Root of the Source Bundle
For Elastic Beanstalk to detect a local Dockerfile, the file must be at the root, or top level, of the uploaded source bundle.
Correct archive layout:
Wrong archive layout:
The second structure is a classic failure mode. Developers zip the project folder instead of zipping the contents of the project folder.
Build the ZIP from Inside the Project Directory
The practical fix is to create the archive from within the directory that already contains the Dockerfile.
That command puts Dockerfile at the root of the archive. If you zip the parent directory instead, Elastic Beanstalk sees one top-level folder and no directly accessible Dockerfile.
Dockerrun.aws.json Changes the Rules
For single-container Docker, Elastic Beanstalk can accept a Dockerrun.aws.json file alone, or a source bundle that contains both Dockerrun.aws.json and Dockerfile.
If both are present, AWS documents that the Dockerfile is used to build the image and Dockerrun.aws.json supplies additional deployment information.
That means Dockerrun.aws.json is not automatically the cause of the error. The real question is whether the platform branch and source bundle layout match the deployment style you chose.
Docker Compose Is a Different Entry Point
On newer Docker platform branches that use Docker Compose, the top-level file Elastic Beanstalk expects is docker-compose.yml, not a standalone Dockerfile as the primary deployment descriptor.
A Dockerfile may still exist if the Compose file builds from it, but the environment is no longer discovering the app through the single-container Docker rules.
So if the environment is configured for Compose and you only uploaded a Dockerfile, the issue is not that the file is “missing.” It is that the platform is expecting a different top-level configuration file.
Check the Actual Filename
This sounds trivial, but it matters:
- it must be named exactly
Dockerfile - case matters on Linux-like systems
- it must not be
Dockerfile.txt - it must not be excluded from the archive you upload
If you are unsure what made it into the bundle, inspect the ZIP explicitly before deployment.
That is a faster truth source than guessing from your editor view.
A Minimal Working Example
For a simple Spring Boot jar deployed with a single-container Docker platform, a minimal Dockerfile can look like this:
If this file is at the top of the source bundle and the environment is a Docker platform that builds local images, Elastic Beanstalk has what it needs.
Common Pitfalls
The biggest mistake is zipping the parent directory instead of the directory contents. The file exists locally, but not at the root of the uploaded bundle.
Another mistake is assuming every Elastic Beanstalk Docker platform branch works the same way. Some branches build from Dockerfile, while others expect Dockerrun.aws.json or docker-compose.yml.
Developers also often debug the Dockerfile itself before confirming whether the environment ever saw the file. If Elastic Beanstalk cannot find it, the bundle structure is the first thing to verify.
Finally, do not mix configuration styles casually. Pick the deployment mode that matches the platform branch and keep the top-level files consistent with it.
Summary
- “Can’t find Dockerfile” usually means bundle layout or platform mismatch, not a broken Docker build.
- For single-container Docker builds,
Dockerfilemust be at the top level of the source bundle. - Build the ZIP from inside the project directory so the archive root is correct.
- Compose-based and ECS-managed Elastic Beanstalk platforms use different top-level deployment files.
- Check the uploaded ZIP contents directly before debugging anything deeper.

