Support podman for building images

Closes gh-30196
This commit is contained in:
Scott Frederick
2022-03-11 16:39:07 -06:00
parent 7ad538cd84
commit de321b00b7
15 changed files with 227 additions and 84 deletions

View File

@@ -25,7 +25,7 @@ The `build-image` goal requires access to a Docker daemon.
By default, it will communicate with a Docker daemon over a local connection.
This works with https://docs.docker.com/install/[Docker Engine] on all supported platforms without configuration.
Environment variables can be set to configure the `build-image` goal to use the https://minikube.sigs.k8s.io/docs/tasks/docker_daemon/[Docker daemon provided by minikube].
Environment variables can be set to configure the `build-image` goal to use an alternative local or remote connection.
The following table shows the environment variables and their values:
|===
@@ -41,8 +41,6 @@ The following table shows the environment variables and their values:
| Path to certificate and key files for HTTPS (required if `DOCKER_TLS_VERIFY=1`, ignored otherwise)
|===
On Linux and macOS, these environment variables can be set using the command `eval $(minikube docker-env)` after minikube has been started.
Docker daemon connection information can also be provided using `docker` parameters in the plugin configuration.
The following table summarizes the available parameters:
@@ -372,13 +370,35 @@ include::../maven/packaging-oci-image/caches-pom.xml[tags=caches]
[[build-image.examples.docker]]
=== Docker Configuration
If you need the plugin to communicate with the Docker daemon using a remote connection instead of the default local connection, the connection details can be provided using `docker` parameters as shown in the following example:
[[build-image.examples.docker.minikube]]
==== Docker Configuration for minikube
The plugin can communicate with the https://minikube.sigs.k8s.io/docs/tasks/docker_daemon/[Docker daemon provided by minikube] instead of the default local connection.
On Linux and macOS, environment variables can be set using the command `eval $(minikube docker-env)` after minikube has been started.
The plugin can also be configured to use the minikube daemon by providing connection details similar to those shown in the following example:
[source,xml,indent=0,subs="verbatim,attributes",tabsize=4]
----
include::../maven/packaging-oci-image/docker-remote-pom.xml[tags=docker-remote]
include::../maven/packaging-oci-image/docker-minikube-pom.xml[tags=docker-minikube]
----
[[build-image.examples.docker.podman]]
==== Docker Configuration for podman
The plugin can communicate with a https://podman.io/[podman container engine].
The plugin can be configured to use podman local connection by providing connection details similar to those shown in the following example:
[source,xml,indent=0,subs="verbatim,attributes",tabsize=4]
----
include::../maven/packaging-oci-image/docker-podman-pom.xml[tags=docker-podman]
----
[[build-image.examples.docker.auth]]
==== Docker Configuration for Authentication
If the builder or run image are stored in a private Docker registry that supports user authentication, authentication details can be provided using `docker.builderRegistry` parameters as shown in the following example:
[source,xml,indent=0,subs="verbatim,attributes",tabsize=4]

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- tag::docker-remote[] -->
<!-- tag::docker-minikube[] -->
<project>
<build>
<plugins>
@@ -17,5 +17,5 @@
</plugins>
</build>
</project>
<!-- end::docker-remote[] -->
<!-- end::docker-minikube[] -->

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- tag::docker-podman[] -->
<project>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<docker>
<host>unix:///run/user/1000/podman/podman.sock</host>
<bindHostToBuilder>true</bindHostToBuilder>
</docker>
</configuration>
</plugin>
</plugins>
</build>
</project>
<!-- end::docker-podman[] -->