Deploying Docker image to AWS elastic beanstalk

Viewed 1832

I have created a spring boot app following this tutorial. Following the tutorial I managed to dockerize my app with the command:

docker-compose up 

My docker-compose.yml file:

version: '3'
services:

  app:
    build: .
    volumes:
    - .:/app
    - ~/.m2:/root/.m2
    working_dir: /app
    ports:
    - 8080:8080
    command: mvn clean spring-boot:run

When I check for docker images afterwards I see the new image for the app. Now I want to deploy this app to AWS elastic beanstalk. When creating the environment with docker platform what do I need to upload for the application code? How do I upload my docker image to aws? I can't find a good tutorial on how to deploy a dockerized app/image to aws like this. I am new to docker so any help would be appreciated!

1 Answers

Update Oct 2020

Docker-compose is now officially supported by EB:

Original answer below

EB does not support docker-compose. To make your container (is it single, or multiple-conatiner setup?) you have to use either single or multi-container EB platforms.

In both cases you have to translate your docker-compose.yml into Dockerrun.aws.json. The file has different form, depending on whether you are using single or multi-container setup.

How do I upload my docker image to aws?

If its single EB setup, you can just provide your Dockerfile to EB and it will take care of everything for you. For multi-conainer EB, you can store your images in public repo such as dockerhub, or a private repo such as ECR.

To translate your docker-compose.yml file into Dockerrun.aws.json, you can try using container-transform tool. It can be helpful, though you will most likely need to manually make further adjustments to the file generated.

Related