Docker is a containerization technology that allows an application to run in an isolated environment while being bundled with all the dependencies it needs to run. So it provides a standard way to run applications in a server agnostic manner.
It also provides an easy way to build, distribute and maintain your application artifacts.
The basic flow is:
If you see above steps, step 2, which is creating a docker file is not standardized, as developers can create images with arbitrary base image and without proper versioning. Also docker file cannot be shared across organization as reusable modules.
But there are higher order tools that address these drawbacks, namely Buildpacks.
Buildpacks is tool that provide a modular way of adding arbitrary content and behavior into an image, while ensuring its manageable, auditable, repeatable and reliable.
Buildpacks build docker images without needing to compose a docker file. It utilizes a builder which uses the best practices to build the image, (the builders are maintained by third party providers like Packeto which is built by Heroku and Cloud Foundry). Buildpacks allows developers to not worry about setting up the runtime environment. It also provides features like inspecting of built images and patching only certain layers of built images with ability to permeate through out the images in an organization. This is useful for security fixes.
While Docker files are used by a lot of companies to create docker images and is the de-facto, there are higher level tools like Buildpack which address the limitations of Docker files namely sharing best practices of building docker images as modules across organizations, meaning no standard way to build images.
Buildpacks have 4 parts:
Example
To create a docker image:
1.
pack build $IMG_NS/$APPLICATION_NAME:$TAG [options]
$IMG_NS - Image namespace on your docker registry/dockerhub
$APPLICATION_NAME - name of docker image
$TAG - Version of image
[options]
--no-pull - If you already have pulled the builder earlier
--publish - do docker push
References
If you use Spring Boot >= 2.3, you can use the maven/gradle plugin to call buildpacks directly, to build docker image containing Spring Boot app. It is as simple.
In Maven :
$ ./mvnw spring-boot:build-image
OR in Gradle :
$ ./gradlew bootBuildImage