### Tag and Push Docker Image to Private Registry (Separate Goals) Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This example shows an alternative approach to pushing images to a private registry, allowing a short image name during build. It uses separate Maven executions to first build the image and then tag it with the full registry hostname before pushing. The pushImage flag is crucial for ensuring the newly tagged image is pushed. ```XML com.spotify docker-maven-plugin my-image ... build-image package build tag-image package tag my-image registry.example.com/my-image ``` -------------------------------- ### Configure Encrypted Docker Registry Password in Maven Settings.xml Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This example shows how to use an encrypted password for Docker registry authentication within Maven's settings.xml. Maven's built-in encryption function can be used to generate encrypted passwords, which are then enclosed in curly braces in the password field for enhanced security. ```XML docker-hub foo {gc4QPLrlgPwHZjAhPw8JPuGzaPitzuyjeBojwCz88j4=} ``` -------------------------------- ### Build Docker Image with Docker Maven Plugin Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This command line instruction initiates the Docker image build process using the configured `docker-maven-plugin`. It cleans the project, packages it, and then triggers the Docker build goal. ```Shell mvn clean package docker:build ``` -------------------------------- ### Specify Docker Image Tags via Command Line Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This command demonstrates how to dynamically specify image tags directly from the command line. The `-DdockerImageTags` property allows passing a comma-separated list of tags to be applied during the build. ```Shell mvn ... docker:build -DpushImageTag -DdockerImageTags=latest,another-tag ``` -------------------------------- ### Configure Docker Image Build in Maven POM Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This Maven plugin configuration demonstrates how to build a Docker image directly from the `pom.xml`. It specifies the image name, base image, entry point, and resources to copy into the image, such as the project's JAR file. This approach allows creating a Docker image without needing a separate `Dockerfile`. ```Maven XML ... com.spotify docker-maven-plugin VERSION GOES HERE example java ["java", "-jar", "/${project.build.finalName}.jar"] / ${project.build.directory} ${project.build.finalName}.jar ... ``` -------------------------------- ### Push Docker Image to Registry Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md To push the Docker image built by the plugin to a configured registry, use this Maven command. The `-DpushImage` flag enables the push operation after the build. ```Shell mvn clean package docker:build -DpushImage ``` -------------------------------- ### Configure Docker Maven Plugin for Private Registry Push (Direct Tagging) Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This configuration demonstrates the simplest method to push Docker images to a private registry using the docker-maven-plugin. By prefixing the with the registry's hostname and port, the plugin automatically directs the push operation to the specified registry. ```XML com.spotify docker-maven-plugin registry.example.com/my-image ... ``` -------------------------------- ### Configure Docker Maven Plugin to Use Dockerfile Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This configuration snippet demonstrates how to instruct the `docker-maven-plugin` to use an existing `Dockerfile` by specifying the `dockerDirectory` element. It also shows how to include additional project resources, such as the service's JAR file, into the Docker image. ```Maven XML ... com.spotify docker-maven-plugin VERSION GOES HERE example docker / ${project.build.directory} ${project.build.finalName}.jar ... ``` -------------------------------- ### Push Specific Docker Image Tags to Registry Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This command allows pushing only specific, pre-configured tags of an image to the registry. The `-DpushImageTag` flag activates this selective push functionality, requiring at least one imageTag to be defined in the plugin configuration. ```Shell mvn clean package docker:build -DpushImageTag ``` -------------------------------- ### Configure Multiple Image Tags for Docker Maven Plugin Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This Maven XML snippet shows how to define multiple tags for a Docker image within the plugin's configuration. These tags will be applied to the image upon build and can be selectively pushed. ```Maven XML ... ... ${project.version} latest ... ``` -------------------------------- ### Perform Local Maven Release for Project Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This snippet provides the shell commands required to perform a local release of a Maven project, typically used by project maintainers. It involves cleaning the release, preparing it, and then performing the release, which often includes deploying artifacts to a remote repository. ```Shell mvn release:clean mvn release:prepare mvn release:perform ``` -------------------------------- ### Bind Docker Maven Plugin Goals to Maven Phases Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This configuration shows how to bind the `build`, `tag`, and `push` goals of the `docker-maven-plugin` to specific Maven lifecycle phases. This allows Docker operations to be automatically executed during standard Maven commands like `mvn package` or `mvn deploy`, which is particularly useful in multi-module projects. ```Maven XML com.spotify docker-maven-plugin VERSION GOES HERE build-image package build tag-image package tag my-image:${project.version} registry.example.com/my-image:${project.version} push-image deploy push registry.example.com/my-image:${project.version} ``` -------------------------------- ### Reference Docker Registry Authentication in Maven pom.xml Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This configuration demonstrates how to reference a pre-defined server ID from Maven's settings.xml within your project's pom.xml. By setting serverId and registryUrl in the docker-maven-plugin configuration, the plugin automatically uses the associated credentials for authentication with the specified registry. ```XML com.spotify docker-maven-plugin VERSION GOES HERE [...] docker-hub https://index.docker.io/v1/ ``` -------------------------------- ### Define Docker Registry Authentication in Maven Settings.xml Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This snippet illustrates how to define Docker registry authentication credentials within Maven's settings.xml file. It configures a server block with an ID, username, password, and optional email for a Docker registry, making these credentials available for use by Maven plugins. ```XML docker-hub foo secret-password foo@foo.bar ``` -------------------------------- ### Set DOCKER_HOST Environment Variable Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This command sets the `DOCKER_HOST` environment variable to connect the Docker client to a remote Docker daemon. By default, the plugin connects to `localhost:2375`. Other Docker-standard environment variables like TLS and certificates are also honored. ```Shell DOCKER_HOST=tcp://:2375 ``` -------------------------------- ### Correcting 'Invalid repository name' for Docker Images Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md A common cause for `HTTP 500 Internal Server Error` is using an invalid Docker repository name, specifically one containing uppercase characters. This often happens when a Maven project version like `SNAPSHOT` is directly used in the image name. Docker repository names must only contain lowercase alphanumeric characters, hyphens, underscores, and periods. It is recommended to use the `` configuration option to include the project version as an image tag instead of in the repository name. ```Docker Invalid repository name ... only [a-z0-9-_.] are allowed ``` -------------------------------- ### Diagnosing HTTP 500 Internal Server Error from Docker Daemon Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md The `InternalServerErrorException: HTTP 500 Internal Server Error` indicates an issue within the Docker daemon itself, reported via the plugin's communication with the Docker Remote API. This is a generic error from the daemon. To investigate, check the Docker daemon logs (typically at `/var/log/docker.log` or `/var/log/upstart/docker.log`) for more specific details about the underlying problem. ```Java Caused by: com.spotify.docker.client.shaded.javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error ``` -------------------------------- ### Force Overwrite Docker Image Tags on Build Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This configuration option forces the Docker Maven Plugin to overwrite existing image tags every time a new image is built. Setting `` to `true` ensures that tags are always updated. ```Maven XML ... ... true ... ... ``` -------------------------------- ### Remove Docker Image with Docker Maven Plugin Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This Maven command allows you to remove a Docker image by its name using the `docker:removeImage` goal. Specify the image to be removed using the `-DimageName` flag. ```Shell mvn docker:removeImage -DimageName=foobar ``` -------------------------------- ### Resolving 'docker has type STRING' Error in Maven Source: https://github.com/spotify/docker-maven-plugin/blob/master/README.md This error occurs when a Maven property named 'docker' conflicts with the `docker-maven-plugin`'s internal use of 'docker' as an object. It indicates that a string property is being used where an object is expected by the plugin. To resolve this, rename the conflicting 'docker' property in your `pom.xml`. ```Maven [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.0.21:build (default) on project <....>: Exception caught: system properties: docker has type STRING rather than OBJECT ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.