This Application will create a docker image for a spring boot application. then we'll deploy and manage the docker images on docker hub.
Here are some of the project's best features:
- Build Docker Image
- Push docker image to docker hub
- Deploy the docker image locally
- swagger UI to test the REST api endpoints
1. Build Project
mvn clean install -Dmaven.test.skip=true
2. Create a dockerfile
FROM openjdk:17-jdk-alpine EXPOSE 8080 ADD target/springboot-docker-0.0.1-SNAPSHOT.jar springboot-docker.jar ENTRYPOINT ["java""-jar""/springboot-docker.jar"]
3. Build docker image
docker build -t springboot-docker:latest .
4. Docker run
docker run -d -p 8080:8080 springboot-docker
5. Docker container stop
docker stop
6. Docker login
docker login -u <DOCKER_USERNAME> -p <DOCKER_PASSWORD> docker.io
7. Docker image tag
docker tag springboot-docker:latest <DOCKER_USERNAME>/springboot-docker
8. Docker push
docker push <DOCKER_USERNAME>/springboot-docker
9. Docker pull image
docker pull <DOCKER_USERNAME>/springboot-docker
10. Docker run
docker run -d -p 8080:8080 <DOCKER_USERNAME>/springboot-docker