Skip to content

Commit c055545

Browse files
Kalyan Reddy DaidaKalyan Reddy Daida
Kalyan Reddy Daida
authored and
Kalyan Reddy Daida
committed
Welcome to Stack Simplify
1 parent 45c3ffc commit c055545

File tree

2 files changed

+17
-139
lines changed

2 files changed

+17
-139
lines changed

02-Docker-Installation/README.md

+16
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,19 @@
99
## Docker Desktop on MAC
1010
- https://docs.docker.com/docker-for-mac/
1111

12+
### Troubleshooting Docker Desktop issues on MAC
13+
- Docker Desktop on mac has an issue with MAC **osxkeychain**
14+
- To fix it perform the below steps.
15+
- **Pre-requisite:** Refer below link for additional understanding
16+
- https://medium.com/@dakshika/error-creating-the-docker-image-on-macos-wso2-enterprise-integrator-tooling-dfb5b537b44e
17+
- **Step-1:** Docker Desktop changes
18+
- Open Docker Desktop --> Preferences
19+
- Uncheck the option named **Securely store Docker logins in macOS keychain**
20+
- **Step-2:** Go to **config.json** file in **.docker** folder
21+
- Sample Reference Location:
22+
- /Users/<userid>/.docker/config.json
23+
- ~/.docker/config.json
24+
- Remove the line **“credSstore” : “osxkeychain”,** in config.json
25+
26+
27+
+1-139
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,4 @@
1-
# Dockerize Spring Boot REST API Application
2-
3-
## Step-1: Pre-requsites - Create Simple SpringBoot HelloWorld REST API
4-
- Create a simple Helloworld rest api
5-
- In our case, we will downloas this from our course artifacts during project setup.
6-
- Run locally and test
7-
- Access Helloworld REST API
8-
- http://localhost:8080/hello
9-
- http://localhost:8080/hello-bean
10-
```json
11-
{
12-
"message": "Hello World Bean",
13-
"appversion": "V1"
14-
}
15-
```
16-
17-
## Step-2: Create Dockerfile
18-
- Create Dockerfile on Application root folder
19-
20-
```
21-
FROM openjdk:8-jdk-alpine
22-
VOLUME /tmp
23-
EXPOSE 8080
24-
ADD target/*.jar app.jar
25-
ENV JAVA_OPTS=""
26-
ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
27-
```
28-
29-
## Step-3: Update pom.xml with spotify plugin
30-
- Update the pom.xml with Spotify plugin
31-
- For additional reference, please refer below link
32-
- **Important Note: **
33-
- In the below pom.xml, please ensure we replace "stacksimplify" in repository tag with your docker hub id.
34-
- <repository>stacksimplify/${project.name}</repository>
35-
- https://github.com/spotify/dockerfile-maven
36-
- https://mvnrepository.com/artifact/com.spotify/dockerfile-maven-plugin
37-
```xml
38-
<!-- Docker Spotify Plugin -->
39-
<plugin>
40-
<groupId>com.spotify</groupId>
41-
<artifactId>dockerfile-maven-plugin</artifactId>
42-
<version>1.4.13</version>
43-
<executions>
44-
<execution>
45-
<id>default</id>
46-
<goals>
47-
<goal>build</goal>
48-
</goals>
49-
</execution>
50-
</executions>
51-
<configuration>
52-
<repository>stacksimplify/${project.name}</repository>
53-
<tag>${project.version}</tag>
54-
<skipDockerInfo>true</skipDockerInfo>
55-
</configuration>
56-
</plugin>
57-
```
58-
59-
## Step-4: Package as Docker image and Run locally on Docker Desktop.
60-
- Run the below command from application root folder or run the same from Spring Tool Suite IDE
61-
```
62-
mvn clean package
63-
```
64-
- Execute docker commands
65-
- List docker images
66-
- Run the docker image locally
67-
```
68-
docker images
69-
docker run -p 80:8080 stacksimplify/springboot-helloworld-rest-api:1.0.0-RELEASE
70-
```
71-
- Access Helloworld REST API
72-
- http://localhost/hello
73-
- http://localhost/hello-bean
74-
```json
75-
{
76-
"message": "Hello World Bean",
77-
"appversion": "V1"
78-
}
79-
```
80-
81-
## Step-5: Push Docker Image to Docker Hub
82-
- Pre-requisites
83-
- Create an account on docker hub
84-
- https://hub.docker.com/
85-
- Login to docker hub
86-
- Push the newly created image to docker hub.
87-
```
88-
docker login
89-
docker push stacksimplify/springboot-helloworld-rest-api:1.0.0-RELEASE
90-
docker push **YOUR DOCKERHUB REPO NAME**/springboot-helloworld-rest-api:1.0.0-RELEASE
91-
```
92-
- Verify the new repository with **1.0.0-RELEASE** tag should be displayed on Docker Hub.
93-
94-
## Step-6: Spring Boot - Docker Image Versioning
95-
- Update version tag in pom.xml
96-
```xml
97-
<version>2.0.0-RELEASE</version>
98-
```
99-
- Package the new image
100-
```
101-
mvn clean package
102-
```
103-
- Run the docker image locally (if required to test)
104-
```
105-
docker images
106-
docker run -p 80:8080 stacksimplify/springboot-helloworld-rest-api:2.0.0-RELEASE
107-
```
108-
- Push the docker image to Docker Hub
109-
```
110-
docker push stacksimplify/springboot-helloworld-rest-api:2.0.0-RELEASE
111-
```
112-
- Verify the same in Docker Hub. New release tag **2.0.0-RELEASE** should bedisplayed
113-
114-
## Step-7: Run docker image in detached mode
115-
- Run docker image in detached mode (no console output of spring boot application)
116-
- So far we are running in foreground mode where we get the spring boot application console output.
117-
```
118-
docker run -d -p 80:8080 stacksimplify/springboot-helloworld-rest-api:2.0.0-RELEASE
119-
docker ps
120-
```
121-
122-
## Step-8: Docker Essentinal commands
1+
# Docker - Essential Commands
1232
- The belowa are the list of essential commands we are in need
1243

1254
| Commands | Description |
@@ -141,20 +20,3 @@ docker ps
14120
| docker stats | Display a live stream of container(s) resource usage statistics |
14221
| docker top container-id or name | Display the running processes of a container |
14322
| docker version | Show the Docker version information |
144-
145-
## Troubleshooting
146-
- Docker Desktop on mac has an issue with MAC **osxkeychain**
147-
- To fix it perform the below steps.
148-
- **Pre-requisite:** Refer below link for additional understanding
149-
- https://medium.com/@dakshika/error-creating-the-docker-image-on-macos-wso2-enterprise-integrator-tooling-dfb5b537b44e
150-
- **Step-1:** Docker Desktop changes
151-
- Open Docker Desktop --> Preferences
152-
- Uncheck the option named **Securely store Docker logins in macOS keychain**
153-
- **Step-2:** Go to **config.json** file in **.docker** folder
154-
- Sample Reference Location:
155-
- /Users/<userid>/.docker/config.json
156-
- ~/.docker/config.json
157-
- Remove the line **“credSstore” : “osxkeychain”,** in config.json
158-
159-
160-

0 commit comments

Comments
 (0)