Once you have a working Docker image of your application – there are 2 basic approaches to getting it up and running on Elastic Beanstalk. The first option is to create an archive and upload it directly, the second is to upload it to a docker repository (e.g. Docker Hub), and reference the image directly from there.

In this article – I’ll just run through the first option – creating an archive and uploading directly.

Step 1 – Create the Archive

As it’s a single file upload to Amazon – you will need to create a zip file containing the Spring Boot JAR and the associated Dockerfile. As I’m using Maven, I just added the Maven Assembly plugin to the pom.xml (and assembly.xml descriptor to the project) to handle this through the maven packaging process.

With the assembly plugin set up – now when you run mvn package it will create a ZIP file in the target directory, which contains the Spring Boot application jar and the associated Dockerfile.

mvn clean package

Step 2 – Upload to Elastic Beanstalk

Once you have an Amazon AWS account setup – open the AWS console and got to the Elastic Beanstalk dashboard.

Create a new Application

Click on the ‘Create New Application’ link

Create a new environment

On the next page click on the ‘Create web server’ button option

Select a ‘Docker’ environment type

On the next page – select ‘Docker’ from the ‘Predefined configuration’ options:

Upload your new ZIP file

Upload the zip file that was created from the Maven build

Select a URL

You can accept the default one amazon provides – or overwrite it with your own. If you want to use your own domain name you can use Amazons Elastic IP to associate a static IP with the Elastic Beanstalk environment and point your domain at that IP.

No Additional Resources

No need to set up any additional resources for this demo

Accept Defaults

Just accept all the defaults on the next few screens. The final screen will display all the configuration you have specified and give you the option to ‘Launch’ the environment.

Launch complete

After clicking ‘Launch’ – it will take a little while, but eventually a green tick should appear indicating that everything is up and running

Open the site in a Browser

The root URL for your new Elastic Beanstalk environment is shown on your Dashboard – just copy and paste into your browser with your full path and you should see ‘Hello World’!