How Do You Install Spring Framework with Docker?

Problem scenario
You want to deploy the Spring framework with Docker. How do you do this?

Solution
Warning: The last step in this is not a security "recommended practice." Only follow these directions (with sudo docker run…), if the server is not that important or you are in a very secure network. One published book says you can use "sudo docker …" as long as the server is not in production (page 43 of Docker Up and Running).

Prerequisites
This assumes that you have installed Docker. If you need assistance, see this posting.

Procedures
1.a. Install Spring framework with these directions.
1.b. Run these commands:

sudo ln -s /home/ec2-user/gs-spring-boot-docker/complete/target/dependency/BOOT-INF /home/ec2-user/gs-spring-boot-docker/complete/BOOT-INF

sudo ln -s /home/ec2-user/gs-spring-boot-docker/complete/target/dependency/META-INF /home/ec2-user/gs-spring-boot-docker/complete/META-INF

2. Move into the "complete" directory. (To find it, use sudo find / -name complete -type d )
Here is an example: cd /home/jdoe/gs-spring-boot-docker/complete/target/dependency/BOOT-INF/lib/

3. Run this command: docker build -t "ricepaper:contint" .

4. Mentally obtain the image ID with this command: docker images

5. Create the container with this command, but substitute abcd1234 with the image ID (found in step #4):
docker create -it abcd1234 bash

6. Find the container ID with this command: docker ps -a

7. Start the container with a command like this, but substitute efgh5689 with the container ID:
docker start efgh5678

8. Run this command:

sudo docker run -e "SPRING_PROFILES_ACTIVE=prod" -p 8080:8080 -t springio/gs-spring-boot-docker

9. From a web browser, go to the server's IP address over port 8080. That is compose a URL like this where x.x.x.x is the external IP address of the server: http://x.x.x.x:8080

Place that URL that you just created in a web browser. Go to the link. You should see the browser window displaying "Hello Docker World".

Leave a comment

Your email address will not be published. Required fields are marked *