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
VOLUME /tmp
ARG JAR_FILE
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-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,510 points
2,673 views

1 answer to this question.

0 votes

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

Add yo you application.properties

server.port=9001

And add to docker-compose.yml:

version: '1'
services:
  your-service:
    build: .
    ports:
      - '9001:9001'
    environment:
      SERVICE_URL: http://service:9001/path
answered Sep 7, 2018 by Priyaj
• 58,020 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,460 points
703 views
0 votes
1 answer

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

You can't install the certificates created by ...READ MORE

answered Feb 21, 2022 in AWS by Korak
• 5,820 points
754 views
+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,020 points
2,706 views
+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  https://aws.amazon.com/certificate-manager/faqs/ You can't install the certificates ...READ MORE

answered Jul 19, 2018 in AWS by Priyaj
• 58,020 points
1,856 views
+1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP