How to deploy Spring Boot RESTful Web Service Docker img to EC2

0 votes

What I'm trying to do is simple, deploy a Spring Boot RESTful Web Service to EC2 so it's accessible publicly.

For this I need to do the following:

  1. Write Spring Boot web service, containerize and test locally - done

Here is my Dockerfile:

FROM openjdk:8-jdk-alpine
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","","-jar","/app.jar"]

When I docker run this locally on 8080 it works fine (returns static json).

  1. Push to Dockerhub - done
  2. Launch an Amazon Linux AMI on aws and make it http accessible (port 80) - done
  3. Install apache (httpd) and start - done

Here is where I need some help

  1. I run docker image from dockerhub like so

    docker run --rm -p 80:8080 kaspartr/demo

It doesn't allow cause of course the port is taken by apache. And if I stop it and run it is deployed but I cannot access it online.

Can someone please explain how do you deploy docker image into the apache?

Do I need to change the Dockerfile or something else?

Thank you!!

Sep 7, 2018 in AWS by bug_seeker
• 15,550 points

1 answer to this question.

0 votes

Typically I run application on separate port and do docker forward:

Add yo you


And add to docker-compose.yml:

version: '1'
    build: .
      - '9001:9001'
      SERVICE_URL: http://service:9001/path
answered Sep 7, 2018 by Priyaj
• 58,140 points

Related Questions In AWS

0 votes
1 answer

How to create a service using the EC2 launch type?

Hi@akhtar, The following create-service example shows how to create a ...READ MORE

answered Nov 8, 2020 in AWS by MD
• 95,320 points
0 votes
3 answers
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,140 points
+2 votes
1 answer
+1 vote
1 answer

How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service

refer this link You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 58,140 points
+1 vote
1 answer