AWS News Blog

Run Docker Apps Locally Using the Elastic Beanstalk (EB) CLI

The guest blog post below was written by Jaehyun Wie while he was a developer intern on the AWS Elastic Beanstalk Team. It shows you how to run your Docker apps locally using the Elastic Beanstalk Command Line Interface (CLI).


The Elastic Beanstalk command line interface (EB CLI) makes it easier for developers, working with command line tools, to get started with Elastic Beanstalk. Last November, we released a revamped version of the EB CLI that added a number of new commands and made it even simpler to get started. Today, we’ve added new commands to run your app locally.

In this post, we will walk through a simple example of using the new local commands. The remainder of this post will assume that you have the EB CLI v3.3 and Docker 1.6.0  installed. If you do not have the EB CLI installed, see Install the EB CLI using pip (Windows, Linux, OS X or Unix).  To install Docker see Docker installation instructions. Before going any further, make sure that the docker command is on your PATH. If you are using boot2docker, make sure that the boot2docker VM is up and running.

Creating the App
To begin, we will create an app that can be run on an Elastic Beanstalk platform that is preconfigured for Docker:

$ git clone
$ cd eb-python-flask
$ eb init -p "python-3.4-(preconfigured-docker)"

Running the App Locally
In order to run our app locally, all we need to do is use the local run command:

$ eb local run

This command will do everything required to run the Flask app in a Docker container. The terminal will hang while your app is running, and you can kill it at any time by using CTRL+C. By default, the container will listen on port 8080. To run your app on a different port, you can use the –port option:

$ eb local run --port 5000

You can also pass in environment variables at runtime if your app depends on them:

$ eb local run --envvars FLASK_DEBUG=true,APP_VERSION=v1.2.0

Opening Your App in a Browser
Now that your app is running, you can open it in a browser. Open a new terminal and run the following command:

$  eb local open

Viewing Status and Getting Application Logs
You can view the status of your local application like this:

$  eb local status

This will display output that looks like this:

Platform: 64bit Debian jessie v1.2.1 running Python 3.4 (Preconfigured - Docker)
Container name: fdc00101ed4ebf79a5119bb67bf59f56618ce1da
Container ip:
Container running: True
Exposed host port(s): 8080
Full local URL(s):

The local command also maps logs to your current directory so that you can access your application logs. To see where the logs are stored:

$ eb local logs

Each invocation of local run creates a new sub-directory for logs, so your logs will never be overwritten.

To learn more, read Running a Docker Environment Locally with the EB CLI and eb local command documentation.

— Jaehyun Wie, SDE Intern

Jeff Barr

Jeff Barr

Jeff Barr is Chief Evangelist for AWS. He started this blog in 2004 and has been writing posts just about non-stop ever since.