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,350 points
694 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
• 56,520 points

Related Questions In AWS

0 votes
3 answers
0 votes
1 answer

How to find unused Amazon EC2 security groups?

Select all and delete there you can ...READ MORE

answered Jul 9, 2018 in AWS by Priyaj
• 56,520 points
392 views
0 votes
1 answer

How to get AWS account/service cost using CloudWatch API?

You can check this link for a ...READ MORE

answered Jul 13, 2018 in AWS by Priyaj
• 56,520 points
147 views
0 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
• 56,520 points
154 views
0 votes
1 answer
0 votes
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
• 56,520 points
70 views
0 votes
1 answer