Repository: rhuss/docker-maven-plugin Branch: master Commit: 2d926fe57c81 Files: 463 Total size: 1.9 MB Directory structure: gitextract_a108wrnn/ ├── .circleci/ │ └── config.yml ├── .codecov.yml ├── .github/ │ └── ISSUE_TEMPLATE.md ├── .gitignore ├── .mvn/ │ ├── jvm.config │ ├── maven.config │ └── wrapper/ │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── CONTRIBUTING.md ├── Jenkinsfile ├── LICENSE ├── README.md ├── doc/ │ ├── changelog.md │ ├── ci-docs.sh │ ├── examples.md │ ├── howto-release.md │ ├── integration-tests.md │ ├── intro.md │ ├── migration-0.9.x.md │ ├── readme-0.9.x.md │ └── update_issue_links.sh ├── it/ │ ├── README.md │ ├── docker-compose/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── docker/ │ │ ├── Dockerfile │ │ ├── docker-compose.yml │ │ └── j4p.war │ ├── dockerfile/ │ │ ├── README.md │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── docker/ │ │ │ ├── Dockerfile │ │ │ └── welcome.txt │ │ ├── java/ │ │ │ └── io/ │ │ │ └── fabric8/ │ │ │ └── dmp/ │ │ │ └── samples/ │ │ │ └── dockerfile/ │ │ │ └── HelloWorldServlet.java │ │ └── webapp/ │ │ └── WEB-INF/ │ │ └── web.xml │ ├── dockerignore/ │ │ ├── .maven-dockerignore │ │ ├── Dockerfile │ │ └── pom.xml │ ├── healthcheck/ │ │ └── pom.xml │ ├── helloworld/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ └── java/ │ │ │ └── io/ │ │ │ └── fabric8/ │ │ │ └── dmp/ │ │ │ └── sample/ │ │ │ └── helloworld/ │ │ │ └── App.java │ │ └── test/ │ │ └── java/ │ │ └── io/ │ │ └── fabric8/ │ │ └── dmp/ │ │ └── sample/ │ │ └── helloworld/ │ │ └── AppTest.java │ ├── log/ │ │ └── pom.xml │ ├── net/ │ │ └── pom.xml │ ├── pom.xml │ ├── properties/ │ │ └── pom.xml │ ├── run-java/ │ │ ├── Dockerfile │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── HelloWorld.java │ ├── smallest/ │ │ ├── Dockerfile │ │ └── pom.xml │ ├── test.xml │ ├── volume/ │ │ └── pom.xml │ └── zero-config/ │ ├── Dockerfile │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── HelloWorld.java ├── mvnw ├── pom.xml ├── release.groovy ├── release.sh ├── samples/ │ ├── README.md │ ├── cargo-jolokia/ │ │ ├── pom.xml │ │ └── src/ │ │ └── test/ │ │ └── java/ │ │ └── io/ │ │ └── fabric8/ │ │ └── maven/ │ │ └── docker/ │ │ └── sample/ │ │ └── jolokia/ │ │ └── VersionIT.java │ ├── custom-net/ │ │ └── pom.xml │ ├── data-jolokia/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ └── docker/ │ │ │ ├── assembly.xml │ │ │ ├── demo/ │ │ │ │ ├── .maven-dockerignore │ │ │ │ ├── Dockerfile │ │ │ │ ├── Dockerfile.test │ │ │ │ ├── jolokia-it.war │ │ │ │ ├── jolokia.war │ │ │ │ └── please-ignore/ │ │ │ │ └── me.md │ │ │ ├── environment.properties │ │ │ └── hello.sh │ │ └── test/ │ │ └── java/ │ │ └── io/ │ │ └── fabric8/ │ │ └── maven/ │ │ └── docker/ │ │ └── sample/ │ │ └── jolokia/ │ │ └── VersionIT.java │ ├── docker-compose/ │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── docker/ │ │ ├── Dockerfile │ │ ├── docker-compose.yml │ │ └── j4p.war │ ├── dockerfile/ │ │ ├── README.md │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ ├── docker/ │ │ │ ├── Dockerfile │ │ │ └── welcome.txt │ │ ├── java/ │ │ │ └── io/ │ │ │ └── fabric8/ │ │ │ └── dmp/ │ │ │ └── samples/ │ │ │ └── dockerfile/ │ │ │ └── HelloWorldServlet.java │ │ └── webapp/ │ │ └── WEB-INF/ │ │ └── web.xml │ ├── dockerignore/ │ │ ├── .maven-dockerignore │ │ ├── Dockerfile │ │ └── pom.xml │ ├── healthcheck/ │ │ └── pom.xml │ ├── helloworld/ │ │ ├── pom.xml │ │ └── src/ │ │ ├── main/ │ │ │ └── java/ │ │ │ └── io/ │ │ │ └── fabric8/ │ │ │ └── dmp/ │ │ │ └── sample/ │ │ │ └── helloworld/ │ │ │ └── App.java │ │ └── test/ │ │ └── java/ │ │ └── io/ │ │ └── fabric8/ │ │ └── dmp/ │ │ └── sample/ │ │ └── helloworld/ │ │ └── AppTest.java │ ├── log/ │ │ └── pom.xml │ ├── multi-wait/ │ │ └── pom.xml │ ├── net/ │ │ └── pom.xml │ ├── pom.xml │ ├── properties/ │ │ └── pom.xml │ ├── run-java/ │ │ ├── Dockerfile │ │ ├── pom.xml │ │ └── src/ │ │ └── main/ │ │ └── java/ │ │ └── HelloWorld.java │ ├── smallest/ │ │ ├── Dockerfile │ │ └── pom.xml │ ├── spring-boot-with-jib/ │ │ ├── README.md │ │ ├── pom.xml │ │ ├── src/ │ │ │ └── main/ │ │ │ └── java/ │ │ │ └── io/ │ │ │ └── fabric8/ │ │ │ └── maven/ │ │ │ └── sample/ │ │ │ └── springboot/ │ │ │ └── jib/ │ │ │ ├── Application.java │ │ │ └── HelloController.java │ │ └── static/ │ │ └── testFile.txt │ ├── test.xml │ ├── volume/ │ │ └── pom.xml │ └── zero-config/ │ ├── Dockerfile │ ├── pom.xml │ └── src/ │ └── main/ │ └── java/ │ └── HelloWorld.java └── src/ ├── main/ │ ├── asciidoc/ │ │ ├── inc/ │ │ │ ├── _authentication.adoc │ │ │ ├── _docker-build.adoc │ │ │ ├── _docker-logs.adoc │ │ │ ├── _docker-push.adoc │ │ │ ├── _docker-remove.adoc │ │ │ ├── _docker-save.adoc │ │ │ ├── _docker-source.adoc │ │ │ ├── _docker-start.adoc │ │ │ ├── _docker-stop.adoc │ │ │ ├── _docker-tag.adoc │ │ │ ├── _docker-volume-create.adoc │ │ │ ├── _docker-volume-remove.adoc │ │ │ ├── _docker-watch.adoc │ │ │ ├── _external-configuration.adoc │ │ │ ├── _global-configuration.adoc │ │ │ ├── _goals.adoc │ │ │ ├── _image-configuration.adoc │ │ │ ├── _implicit-properties.adoc │ │ │ ├── _installation.adoc │ │ │ ├── _introduction.adoc │ │ │ ├── _links.adoc │ │ │ ├── _registry.adoc │ │ │ ├── build/ │ │ │ │ ├── _assembly.adoc │ │ │ │ ├── _buildargs.adoc │ │ │ │ ├── _configuration.adoc │ │ │ │ ├── _healthcheck.adoc │ │ │ │ └── _overview.adoc │ │ │ ├── external/ │ │ │ │ ├── _docker_compose.adoc │ │ │ │ └── _property_configuration.adoc │ │ │ ├── image/ │ │ │ │ ├── _configuration.adoc │ │ │ │ ├── _example.adoc │ │ │ │ ├── _example_imagesMap.adoc │ │ │ │ └── _naming.adoc │ │ │ ├── misc/ │ │ │ │ ├── _env.adoc │ │ │ │ └── _startup.adoc │ │ │ ├── push/ │ │ │ │ ├── _configuration.adoc │ │ │ │ └── _overview.adoc │ │ │ ├── start/ │ │ │ │ ├── _configuration.adoc │ │ │ │ ├── _depends-on.adoc │ │ │ │ ├── _links.adoc │ │ │ │ ├── _logging.adoc │ │ │ │ ├── _network.adoc │ │ │ │ ├── _overview.adoc │ │ │ │ ├── _port-mapping.adoc │ │ │ │ ├── _restart.adoc │ │ │ │ ├── _volumes.adoc │ │ │ │ └── _wait.adoc │ │ │ └── watch/ │ │ │ ├── _configuration.adoc │ │ │ └── _overview.adoc │ │ └── index.adoc │ ├── java/ │ │ └── io/ │ │ └── fabric8/ │ │ └── maven/ │ │ └── docker/ │ │ ├── AbstractBuildSupportMojo.java │ │ ├── AbstractDockerMojo.java │ │ ├── BuildMojo.java │ │ ├── LogsMojo.java │ │ ├── PushMojo.java │ │ ├── RemoveMojo.java │ │ ├── RunMojo.java │ │ ├── SaveMojo.java │ │ ├── SourceMojo.java │ │ ├── StartMojo.java │ │ ├── StopMojo.java │ │ ├── TagMojo.java │ │ ├── VolumeCreateMojo.java │ │ ├── VolumeRemoveMojo.java │ │ ├── WatchMojo.java │ │ ├── access/ │ │ │ ├── AuthConfig.java │ │ │ ├── BuildOptions.java │ │ │ ├── ContainerCreateConfig.java │ │ │ ├── ContainerHostConfig.java │ │ │ ├── ContainerNetworkingConfig.java │ │ │ ├── DockerAccess.java │ │ │ ├── DockerAccessException.java │ │ │ ├── DockerConnectionDetector.java │ │ │ ├── DockerMachine.java │ │ │ ├── ExecException.java │ │ │ ├── KeyStoreUtil.java │ │ │ ├── NetworkCreateConfig.java │ │ │ ├── PortMapping.java │ │ │ ├── UrlBuilder.java │ │ │ ├── VolumeCreateConfig.java │ │ │ ├── chunked/ │ │ │ │ ├── BuildJsonResponseHandler.java │ │ │ │ ├── EntityStreamReaderUtil.java │ │ │ │ └── PullOrPushResponseJsonHandler.java │ │ │ ├── ecr/ │ │ │ │ ├── AwsSigner4.java │ │ │ │ ├── AwsSigner4Request.java │ │ │ │ └── EcrExtendedAuth.java │ │ │ ├── hc/ │ │ │ │ ├── ApacheHttpClientDelegate.java │ │ │ │ ├── DockerAccessWithHcClient.java │ │ │ │ ├── http/ │ │ │ │ │ ├── HttpClientBuilder.java │ │ │ │ │ └── HttpRequestException.java │ │ │ │ ├── unix/ │ │ │ │ │ ├── UnixConnectionSocketFactory.java │ │ │ │ │ ├── UnixSocket.java │ │ │ │ │ └── UnixSocketClientBuilder.java │ │ │ │ ├── util/ │ │ │ │ │ ├── AbstractNativeClientBuilder.java │ │ │ │ │ ├── AbstractNativeSocketFactory.java │ │ │ │ │ └── ClientBuilder.java │ │ │ │ └── win/ │ │ │ │ ├── NamedPipe.java │ │ │ │ ├── NamedPipeClientBuilder.java │ │ │ │ ├── NpipeConnectionSocketFactory.java │ │ │ │ └── NpipeSocketAddress.java │ │ │ ├── log/ │ │ │ │ ├── LogCallback.java │ │ │ │ ├── LogGetHandle.java │ │ │ │ └── LogRequestor.java │ │ │ └── util/ │ │ │ ├── EnvCommand.java │ │ │ ├── ExternalCommand.java │ │ │ ├── LocalSocketUtil.java │ │ │ └── RequestUtil.java │ │ ├── assembly/ │ │ │ ├── AllFilesExecCustomizer.java │ │ │ ├── ArchiverCustomizer.java │ │ │ ├── AssemblyFiles.java │ │ │ ├── BuildDirs.java │ │ │ ├── DockerAssemblyConfigurationSource.java │ │ │ ├── DockerAssemblyManager.java │ │ │ ├── DockerFileBuilder.java │ │ │ ├── DockerFileKeyword.java │ │ │ ├── DockerFileOption.java │ │ │ └── MappingTrackArchiver.java │ │ ├── config/ │ │ │ ├── ArchiveCompression.java │ │ │ ├── Arguments.java │ │ │ ├── AssemblyConfiguration.java │ │ │ ├── AssemblyMode.java │ │ │ ├── BuildImageConfiguration.java │ │ │ ├── BuildImageSelectMode.java │ │ │ ├── CleanupMode.java │ │ │ ├── ConfigHelper.java │ │ │ ├── DockerMachineConfiguration.java │ │ │ ├── HealthCheckConfiguration.java │ │ │ ├── HealthCheckMode.java │ │ │ ├── ImageConfiguration.java │ │ │ ├── ImagePullPolicy.java │ │ │ ├── LogConfiguration.java │ │ │ ├── NetworkConfig.java │ │ │ ├── RegistryAuthConfiguration.java │ │ │ ├── RestartPolicy.java │ │ │ ├── RunImageConfiguration.java │ │ │ ├── RunVolumeConfiguration.java │ │ │ ├── StopMode.java │ │ │ ├── UlimitConfig.java │ │ │ ├── VolumeConfiguration.java │ │ │ ├── WaitConfiguration.java │ │ │ ├── WatchImageConfiguration.java │ │ │ ├── WatchMode.java │ │ │ └── handler/ │ │ │ ├── ExternalConfigHandler.java │ │ │ ├── ExternalConfigHandlerException.java │ │ │ ├── ImageConfigResolver.java │ │ │ ├── compose/ │ │ │ │ ├── ComposeUtils.java │ │ │ │ ├── DockerComposeConfigHandler.java │ │ │ │ ├── DockerComposeConfiguration.java │ │ │ │ └── DockerComposeServiceWrapper.java │ │ │ └── property/ │ │ │ ├── ConfigKey.java │ │ │ ├── PropertyConfigHandler.java │ │ │ ├── PropertyMode.java │ │ │ ├── ValueCombinePolicy.java │ │ │ └── ValueProvider.java │ │ ├── log/ │ │ │ ├── DefaultLogCallback.java │ │ │ ├── LogDispatcher.java │ │ │ ├── LogOutput.java │ │ │ ├── LogOutputSpec.java │ │ │ ├── LogOutputSpecFactory.java │ │ │ └── SharedPrintStream.java │ │ ├── model/ │ │ │ ├── Container.java │ │ │ ├── ContainerDetails.java │ │ │ ├── ContainersListElement.java │ │ │ ├── ExecDetails.java │ │ │ ├── Image.java │ │ │ ├── ImageArchiveManifest.java │ │ │ ├── ImageArchiveManifestAdapter.java │ │ │ ├── ImageArchiveManifestEntry.java │ │ │ ├── ImageArchiveManifestEntryAdapter.java │ │ │ ├── ImageDetails.java │ │ │ ├── Network.java │ │ │ └── NetworksListElement.java │ │ ├── service/ │ │ │ ├── ArchiveService.java │ │ │ ├── BuildService.java │ │ │ ├── ContainerTracker.java │ │ │ ├── DockerAccessFactory.java │ │ │ ├── ImagePullManager.java │ │ │ ├── JibBuildService.java │ │ │ ├── MojoExecutionService.java │ │ │ ├── QueryService.java │ │ │ ├── RegistryService.java │ │ │ ├── RunService.java │ │ │ ├── ServiceHub.java │ │ │ ├── ServiceHubFactory.java │ │ │ ├── VolumeService.java │ │ │ ├── WaitService.java │ │ │ ├── WatchService.java │ │ │ └── helper/ │ │ │ └── StartContainerExecutor.java │ │ ├── util/ │ │ │ ├── AnsiLogger.java │ │ │ ├── AuthConfigFactory.java │ │ │ ├── AutoPullMode.java │ │ │ ├── ContainerNamingUtil.java │ │ │ ├── CredentialHelperClient.java │ │ │ ├── DeepCopy.java │ │ │ ├── DockerFileUtil.java │ │ │ ├── DockerPathUtil.java │ │ │ ├── EnvUtil.java │ │ │ ├── FormatParameterReplacer.java │ │ │ ├── GavLabel.java │ │ │ ├── ImageArchiveUtil.java │ │ │ ├── ImageName.java │ │ │ ├── ImageNameFormatter.java │ │ │ ├── JibServiceUtil.java │ │ │ ├── JsonFactory.java │ │ │ ├── Logger.java │ │ │ ├── MojoParameters.java │ │ │ ├── NamePatternUtil.java │ │ │ ├── StartOrderResolver.java │ │ │ ├── SuffixFileFilter.java │ │ │ ├── Task.java │ │ │ ├── TimestampFactory.java │ │ │ ├── VolumeBindingUtil.java │ │ │ └── aws/ │ │ │ └── AwsSdkAuthConfigFactory.java │ │ └── wait/ │ │ ├── ExitCodeChecker.java │ │ ├── HealthCheckChecker.java │ │ ├── HttpPingChecker.java │ │ ├── LogMatchCallback.java │ │ ├── LogWaitChecker.java │ │ ├── LogWaitCheckerCallback.java │ │ ├── PreconditionFailedException.java │ │ ├── TcpPortChecker.java │ │ ├── WaitChecker.java │ │ ├── WaitTimeoutException.java │ │ └── WaitUtil.java │ └── resources/ │ ├── META-INF/ │ │ └── plexus/ │ │ └── components.xml │ └── assemblies/ │ ├── artifact-with-dependencies.xml │ ├── artifact.xml │ ├── hawt-app.xml │ ├── project.xml │ └── rootWar.xml └── test/ ├── java/ │ ├── com/ │ │ └── amazonaws/ │ │ └── auth/ │ │ ├── AWSCredentials.java │ │ ├── AWSSessionCredentials.java │ │ └── DefaultAWSCredentialsProviderChain.java │ ├── integration/ │ │ ├── DockerAccessIT.java │ │ ├── DockerAccessWinIT.java │ │ └── DockerMachineIT.java │ └── io/ │ └── fabric8/ │ └── maven/ │ └── docker/ │ ├── BaseMojoTest.java │ ├── RemoveMojoTest.java │ ├── SaveMojoTest.java │ ├── StopMojoTest.java │ ├── UrlBuilderTest.java │ ├── VolumeCreateMojoTest.java │ ├── VolumeRemoveMojoTest.java │ ├── access/ │ │ ├── BuildConfigTest.java │ │ ├── ContainerCreateConfigTest.java │ │ ├── ContainerHostConfigTest.java │ │ ├── DockerConnectionDetectorTest.java │ │ ├── KeyStoreUtilTest.java │ │ ├── PortMappingPropertyWriteHelperTest.java │ │ ├── PortMappingTest.java │ │ ├── ecr/ │ │ │ ├── AwsSigner4RequestTest.java │ │ │ └── EcrExtendedAuthTest.java │ │ ├── hc/ │ │ │ └── DockerAccessWithHcClientTest.java │ │ └── log/ │ │ └── LogRequestorTest.java │ ├── assembly/ │ │ ├── DockerAssemblyConfigurationSourceTest.java │ │ ├── DockerAssemblyManagerTest.java │ │ ├── DockerFileBuilderTest.java │ │ └── MappingTrackArchiverTest.java │ ├── config/ │ │ ├── BuildImageConfigurationTest.java │ │ ├── BuildImageConfigurationWithMavenDepsTest.java │ │ ├── CleanupModeTest.java │ │ ├── ConfigHelperTest.java │ │ ├── HealthCheckConfigTest.java │ │ ├── ImageConfigResolverTest.java │ │ ├── LogConfigurationTest.java │ │ ├── NetworkingConfigTest.java │ │ ├── RegistryAuthConfigurationTest.java │ │ ├── UlimitConfigTest.java │ │ └── handler/ │ │ ├── AbstractConfigHandlerTest.java │ │ ├── ArchiveCompressionTest.java │ │ ├── compose/ │ │ │ ├── ComposeUtilsTest.java │ │ │ └── DockerComposeConfigHandlerTest.java │ │ └── property/ │ │ ├── PropertyConfigHandlerTest.java │ │ ├── PropertyModeTest.java │ │ └── ValueProviderTest.java │ ├── log/ │ │ ├── DefaultLogCallbackTest.java │ │ ├── LogOutputSpecDateTest.java │ │ ├── LogOutputSpecFactoryTest.java │ │ └── LogOutputSpecTest.java │ ├── model/ │ │ ├── ContainerDetailsTest.java │ │ ├── ContainerListElementTest.java │ │ ├── ImageArchiveManifestAdapterTest.java │ │ ├── ImageArchiveManifestEntryAdapterTest.java │ │ └── ImageDetailsTest.java │ ├── service/ │ │ ├── BuildServiceTest.java │ │ ├── ContainerTrackerTest.java │ │ ├── JibBuildServiceTest.java │ │ ├── LoadImageTest.java │ │ ├── MojoExecutionServiceTest.java │ │ ├── RegistryServiceTest.java │ │ ├── RunServiceTest.java │ │ ├── VolumeServiceTest.java │ │ └── helper/ │ │ └── StartContainerExecutorTest.java │ ├── util/ │ │ ├── AnsiLoggerTest.java │ │ ├── AuthConfigFactoryTest.java │ │ ├── AuthConfigTest.java │ │ ├── AutoPullModeTest.java │ │ ├── ContainerNamingUtilTest.java │ │ ├── CredentialHelperClientTest.java │ │ ├── DockerFileUtilTest.java │ │ ├── DockerPathUtilTest.java │ │ ├── EnvUtilTest.java │ │ ├── GavLabelTest.java │ │ ├── ImageArchiveUtilTest.java │ │ ├── ImageNameFormatterTest.java │ │ ├── ImageNameTest.java │ │ ├── JibServiceUtilTest.java │ │ ├── NamePatternUtilTest.java │ │ ├── PathTestUtil.java │ │ ├── StartOrderResolverTest.java │ │ ├── TimestampFactoryTest.java │ │ ├── VolumeBindingUtilTest.java │ │ ├── WaitUtilTest.java │ │ └── aws/ │ │ └── AwsSdkAuthConfigFactoryTest.java │ └── wait/ │ ├── ExitCodeCheckerTest.java │ ├── LogMatchCallbackTest.java │ └── LogWaitCheckerTest.java └── resources/ ├── compose/ │ ├── docker-compose-network-aliases.yml │ ├── docker-compose.yml │ └── version/ │ ├── compose-no-version.yml │ ├── compose-version-2.yml │ ├── compose-version-2x.yml │ └── compose-wrong-version.yml ├── docker/ │ ├── Dockerfile.multiline_label.test │ ├── Dockerfile.test │ ├── Dockerfile_assembly_verify_copy_chown_valid.test │ ├── Dockerfile_assembly_verify_copy_invalid.test │ ├── Dockerfile_assembly_verify_copy_valid.test │ ├── Dockerfile_optimised.test │ ├── Dockerfile_tcp.test │ ├── Dockerfile_udp.test │ ├── containerCreateConfigAll.json │ └── containerHostConfigAll.json ├── interpolate/ │ ├── at/ │ │ ├── Dockerfile_1 │ │ └── Dockerfile_1.expected │ ├── none/ │ │ ├── Dockerfile_1 │ │ └── Dockerfile_1.expected │ └── var/ │ ├── Dockerfile_1 │ └── Dockerfile_1.expected └── io/ └── fabric8/ └── maven/ └── docker/ ├── access/ │ ├── certpath/ │ │ ├── ca.pem │ │ ├── cert.pem │ │ └── key.pem │ ├── keys/ │ │ ├── ecdsa.pem │ │ ├── invalid.pem │ │ ├── pkcs1.pem │ │ └── pkcs8.pem │ └── test-environment.props └── util/ ├── Dockerfile_from_simple ├── Dockerfile_multi_stage ├── Dockerfile_multi_stage_named_build_stages ├── Dockerfile_multi_stage_named_redundant_build_stages ├── Dockerfile_multi_stage_with_args ├── openshift_nologin_config.yaml └── openshift_simple_config.yaml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .circleci/config.yml ================================================ version: 2 jobs: # Build Website doc: working_directory: ~/fabric8io/dmp-docs docker: - image: circleci/node:9-browsers steps: - checkout - run: - git config --global user.email "circleci@fabric8.io" - git config --global user.name "CircleCI" - run: ./doc/ci-docs.sh # Run unit tests build: working_directory: ~/fabric8io/docker-maven-plugin docker: - image: circleci/openjdk:11 steps: - checkout - restore_cache: key: dmp-{{ checksum "pom.xml" }} - run: mvn install -Pjacoco - run: bash <(curl -s https://codecov.io/bash) - save_cache: key: dmp-{{ checksum "pom.xml" }} paths: - ~/.m2 # Run integration tests e2e-tests: working_directory: ~/fabric8io/docker-maven-plugin machine: true steps: - checkout - restore_cache: key: dmp-{{ checksum "pom.xml" }} - run: command: | mvn clean install -DskipTests PROJECT_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) cd it/ find . -type f -exec sed -i 's/0.29-SNAPSHOT/'"$PROJECT_VERSION"'/g' {} + mvn clean install - save_cache: key: dmp-{{ checksum "pom.xml" }} paths: - ~/.m2 sonar-pr: working_directory: ~/fabric8io/dmp-sonar-pr docker: - image: circleci/openjdk:11 steps: - checkout - restore_cache: key: dmp-sonar-pr-{{ checksum "pom.xml" }} - run: | if [ -n "${CIRCLE_PR_NUMBER}" ]; then mvn clean -Pjacoco org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \ -Dsonar.pullrequest.base=master \ -Dsonar.pullrequest.branch=${CIRCLE_BRANCH} \ -Dsonar.pullrequest.key=${CIRCLE_PR_NUMBER} \ -Dsonar.pullrequest.provider=GitHub \ -Dsonar.pullrequest.github.repository=fabric8io/docker-maven-plugin \ -Dsonar.github.oauth=${GITHUB_COMMENT_TOKEN} \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.organization=default \ -Dsonar.login=${SONARQUBE_TOKEN} else echo "No Sonar PR analysis as this is not a pull request" fi - save_cache: key: dmp-sonar-pr-{{ checksum "pom.xml" }} paths: - ~/.m2 sonar: working_directory: ~/fabric8io/dmp-sonar docker: - image: circleci/openjdk:11 steps: - checkout - restore_cache: key: dmp-sonar-{{ checksum "pom.xml" }} - run: | mvn clean -Pjacoco org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar \ -Dsonar.host.url=https://sonarcloud.io \ -Dsonar.organization=default \ -Dsonar.login=${SONARQUBE_TOKEN} - save_cache: key: dmp-sonar-{{ checksum "pom.xml" }} paths: - ~/.m2 workflows: version: 2 all: jobs: - doc: filters: branches: only: dmp.fabric8.io - build - e2e-tests - sonar-pr - sonar: filters: branches: only: master ================================================ FILE: .codecov.yml ================================================ coverage: range: "45...90" precision: 2 round: down status: project: default: threshold: "2%" comment: layout: "header, diff, tree, sunburst" require_changes: true ================================================ FILE: .github/ISSUE_TEMPLATE.md ================================================ ### Description ### Info * d-m-p version : * Maven version (`mvn -v`) : ``` ``` * Docker version : * If it's a bug, how to reproduce : * If it's a feature request, what is your use case : * Sample project : *[GitHub Clone URL]* ================================================ FILE: .gitignore ================================================ .idea/ .DS_Store target/ *.iml .classpath .project .settings .*.md.html temp ================================================ FILE: .mvn/jvm.config ================================================ -Xmx2048m -Djava.awt.headless=true -XX:+UseG1GC -XX:+UseStringDeduplication ================================================ FILE: .mvn/maven.config ================================================ -Dmaven.artifact.threads=8 ================================================ FILE: .mvn/wrapper/maven-wrapper.properties ================================================ distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip ================================================ FILE: CONTRIBUTING.md ================================================ ## Contributing You want to contribute ? Awesome ! We **♥︎♥︎ LOVE ♥︎♥︎** contributions ;-) Here some things to check out when doing a PR: * Please sign-off your commits as described below. * If adding a new feature please [update the documentation](https://github.com/fabric8io/docker-maven-plugin/blob/master/src/main/asciidoc/), too. * Don't forget the unit tests. * If adding a new configuration option, don't forget to add this to the [PropertyHandler](https://github.com/fabric8io/docker-maven-plugin/blob/master/src/main/java/io/fabric8/maven/docker/config/handler/property/PropertyConfigHandler.java), too. However, if you can't do some of the points above, please still consider contributing. Simply ask us on `#fabric8` at Freenode or via an GitHub [issue](https://github.com/fabric8io/docker-maven-plugin/issues). We are not dogmatic. ### Signing off your commits Pull requests are highly appreciated and most of them get applied. However, you must sign-off your code so that you certify that your contributions is compatible with the license of this project (which is the [Apache Public License 2](../LICENSE)). The sign-off also certifies that you wrote it or otherwise have the right to pass it on as an open-source patch under the APL 2. The rules are simple: if you can certify the below (from [developercertificate.org](http://developercertificate.org/)): ``` Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` then you just add a line to every git commit message: Signed-off-by: Joe Smith with your real name (first and last name) If you set your `user.name` and `user.email` git configs, you can sign your commit automatically with `git commit -s`. If you forgot this you can use `git commit -s --amend` to add this in retrospective for the last commit. If you need to sign-off multiple commits within a branch, you need to do an interactive rebase with `git rebase -i`. A nice shortcut for signing off every commit in a branch can be provided with this [alias](http://stackoverflow.com/questions/25570947/how-to-use-git-interactive-rebase-for-signing-off-a-series-of-commits) which you can put into your `~/.gitconfig`: ```` [alias] # Usage: git signoff-rebase [base-commit] signoff-rebase = "!EDITOR='sed -i -re s/^pick/e/' sh -c 'git rebase -i $1 && while test -f .git/rebase-merge/interactive; do git commit --amend --signoff --no-edit && git rebase --continue; done' -" # Ideally we would use GIT_SEQUENCE_EDITOR in the above instead of EDITOR but that's not supported for git < 1.7.8. ```` When sending pull request we prefer that to be a single commit. So please squash your commits with an interactive rebase before sending the pull request. This is nicely explained [here](https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request). Said all this, don't hesitate to ask when there are any problems or you have an issue with this process. ================================================ FILE: Jenkinsfile ================================================ #!/usr/bin/groovy @Library('github.com/fabric8io/fabric8-pipeline-library@master') def dummy mavenNode { dockerNode { checkout scm sh "git remote set-url origin git@github.com:fabric8io/docker-maven-plugin.git" def pipeline = load 'release.groovy' stage 'Stage' def stagedProject = pipeline.stage() stage 'Promote' pipeline.release(stagedProject) } } ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # docker-maven-plugin [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.fabric8/docker-maven-plugin/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/io.fabric8/docker-maven-plugin/) [![Circle CI](https://circleci.com/gh/fabric8io/docker-maven-plugin/tree/master.svg?style=shield)](https://circleci.com/gh/fabric8io/docker-maven-plugin/tree/master) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=io.fabric8%3Adocker-maven-plugin&metric=coverage)](https://sonarcloud.io/dashboard?id=io.fabric8%3Adocker-maven-plugin) [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=io.fabric8%3Adocker-maven-plugin&metric=sqale_index)](https://sonarcloud.io/dashboard?id=io.fabric8%3Adocker-maven-plugin) This is a Maven plugin for building Docker images and managing containers for integration tests. It works with Maven 3.0.5 and Docker 1.6.0 or later. #### Goals | Goal | Description | Default Lifecycle Phase | | ----------------------------------------------------------------------------------------------- | ------------------------------------------------ | ----------------------- | | [`docker:start`](https://fabric8io.github.io/docker-maven-plugin/#docker:start) | Create and start containers | pre-integration-test | | [`docker:stop`](https://fabric8io.github.io/docker-maven-plugin/#docker:stop) | Stop and destroy containers | post-integration-test | | [`docker:build`](https://fabric8io.github.io/docker-maven-plugin/#docker:build) | Build images | install | | [`docker:watch`](https://fabric8io.github.io/docker-maven-plugin/#docker:watch) | Watch for doing rebuilds and restarts | | | [`docker:push`](https://fabric8io.github.io/docker-maven-plugin/#docker:push) | Push images to a registry | deploy | | [`docker:remove`](https://fabric8io.github.io/docker-maven-plugin/#docker:remove) | Remove images from local docker host | post-integration-test | | [`docker:logs`](https://fabric8io.github.io/docker-maven-plugin/#docker:logs) | Show container logs | | | [`docker:source`](https://fabric8io.github.io/docker-maven-plugin/#docker:source) | Attach docker build archive to Maven project | package | | [`docker:save`](https://fabric8io.github.io/docker-maven-plugin/#docker:save) | Save image to a file | | | [`docker:volume-create`](https://fabric8io.github.io/docker-maven-plugin/#docker:volume-create) | Create a volume to share data between containers | pre-integration-test | | [`docker:volume-remove`](https://fabric8io.github.io/docker-maven-plugin/#docker:volume-remove) | Remove a created volume | post-integration-test | #### Documentation * The **[User Manual](https://fabric8io.github.io/docker-maven-plugin)** [[PDF](https://fabric8io.github.io/docker-maven-plugin/docker-maven-plugin.pdf)] has a detailed reference for all and everything. * The [Introduction](doc/intro.md) is a high level overview of this plugin's features and provides an usage example. provided goals and possible configuration parameters. * [Examples](doc/examples.md) are below `samples/` and contain example setups which you can use as blueprints for your own projects. * [ChangeLog](doc/changelog.md) has the release history of this plugin. * [Contributing](CONTRIBUTING.md) explains how you can contribute to this project. Pull requests are highly appreciated! #### Docker API Support * Docker 1.6 (**v1.18**) is the minimal required version * Docker 1.8.1 (**v1.20**) is required for `docker:watch` * Docker 1.9 (**v1.21**) is required for using custom networks and build args. ================================================ FILE: doc/changelog.md ================================================ # ChangeLog * **0.34.0** (2020-09-13) - Support `ARG` in `FROM` ([#859](https://github.com/fabric8io/docker-maven-plugin/issues/859)) - Handle authentication tokens returned from credential helpers ([#1348](https://github.com/fabric8io/docker-maven-plugin/issues/1348)) - Migrate from joda-time to java.time ([#1025](https://github.com/fabric8io/docker-maven-plugin/issues/1025)) The handling of Y changes when the week straddle the New year ([Stack Overflow](https://stackoverflow.com/questions/26431882/difference-between-year-of-era-and-week-based-year)) - Fix JSON error when parsin tafs ([#1354](https://github.com/fabric8io/docker-maven-plugin/issues/1354)) - Add `skipPush` option to build image configuration ([#1243](https://github.com/fabric8io/docker-maven-plugin/issues/1243)) - docker.container..ip property is no longer set ([#1242](https://github.com/fabric8io/docker-maven-plugin/issues/1242)) - Support `squash` in build options to squash newly built layers into a single layer ([#785](https://github.com/fabric8io/docker-maven-plugin/issues/785)) - Support for JIB mode([#1277](https://github.com/fabric8io/docker-maven-plugin/pull/1277)) * **0.33.0** (2020-01-21) - Update to jnr-unixsocket 0.25 to solve concurrency issues ([#552](https://github.com/fabric8io/docker-maven-plugin/issues/552)) - Udate ECR AuthorizationToken URL to new endpoint ([#1317](https://github.com/fabric8io/docker-maven-plugin/issues/1317)) - Allow including `com.amazonaws:aws-java-sdk-core` as plugin dependency to pick up various forms of AWS credentials with which to authenticate at AWS ECR ([#1311](https://github.com/fabric8io/docker-maven-plugin/issues/1311)) * **0.32.0** (2020-01-08) - Support building dockerFile without pushing it to docker server ([#1197](https://github.com/fabric8io/docker-maven-plugin/issues/1197)) - Update to jnr-unixsocket 0.23 - Add null check for null instance in config.json for email ([#1262](https://github.com/fabric8io/docker-maven-plugin/issues/1262)) - Allow merging of image configurations using `` ([#1259](https://github.com/fabric8io/docker-maven-plugin/issues/1259)) - Update to joda-time 2.10.4 ([#706](https://github.com/fabric8io/docker-maven-plugin/issues/706)) - Add docker:build support for 'network' option ([#1030](https://github.com/fabric8io/docker-maven-plugin/issues/1030)) - Avoiding chown to reduce the image size ([#544](https://github.com/fabric8io/docker-maven-plugin/issues/544)) (_Note: Assembly user format `user:user:user` with the third user option has been marked deprecated and will not be available in future versions of plugin_) - Failure referencing a previous staged image in FROM clause ([#1264](https://github.com/fabric8io/docker-maven-plugin/issues/1264)) - Treat bridged and default network mode the same ([#1234](https://github.com/fabric8io/docker-maven-plugin/issues/1234)) - Fix NPE when cacheFrom is missing from config ([#1274](https://github.com/fabric8io/docker-maven-plugin/issues/1274)) - Fix healthy option regression introduced in 0.25.0 ([#1279](https://github.com/fabric8io/docker-maven-plugin/issues/1279)) - Allow killing and removing all spawned containers ([#1182](https://github.com/fabric8io/docker-maven-plugin/issues/1182)) - Deprecated "authToken" for ECR authentication in favor of "auth" ([#1286](https://github.com/fabric8io/docker-maven-plugin/issues/1286)) - Allow overriding of existing image in creation of temporary one with same tag before push ([#838](https://github.com/fabric8io/docker-maven-plugin/issues/838)) - Pick up AWS credentials from ENV variables ([#1310](https://github.com/fabric8io/docker-maven-plugin/issues/1310)) - Fix accidentally disabled logging under certain conditions ([#1291](https://github.com/fabric8io/docker-maven-plugin/issues/1291)) - When stopping containers, try harder to remove containers, even if one fails ([#1251](https://github.com/fabric8io/docker-maven-plugin/issues/1251)) - Added integration tests ([#1209](https://github.com/fabric8io/docker-maven-plugin/issues/1209)) * **0.31.0** (2019-08-10) - Fix test cases on Windows ([#1220](https://github.com/fabric8io/docker-maven-plugin/issues/1220)) - ECR credentials from IAM Task role for ECS Fargate deployment ([#1233](https://github.com/fabric8io/docker-maven-plugin/issues/1233)) - Fix bug in properties names extracted from docker config json file ([#1237](https://github.com/fabric8io/docker-maven-plugin/issues/1237)) - Fix that portPropertyFile is not written anymore ([#1112](https://github.com/fabric8io/docker-maven-plugin/issues/1112)) - Use identity token if found in Docker config.json ([#1249](https://github.com/fabric8io/docker-maven-plugin/issues/1249)) - Allow also starting with an environment variable in `targetDir` of an aseembly config instead of insisting on only absolute path-names ([#1244](https://github.com/fabric8io/docker-maven-plugin/issues/1244)) - Support for pattern matching in `docker:stop` and `docker:remove` ([#1215](https://github.com/fabric8io/docker-maven-plugin/issues/1215)) - Increase interoperability with docker-java by accepting `registry.username` and `registry.password`, too ([#1245](https://github.com/fabric8io/docker-maven-plugin/issues/1245)) * **0.30.0** (2019-04-21) - Restore ANSI color to Maven logging if disabled during plugin execution and enable color for Windows with Maven 3.5.0 or later. Color logging is enabled by default, but disabled if the Maven CLI disables color (e.g. in batch mode) ([#1108](https://github.com/fabric8io/docker-maven-plugin/issues/1108)) - Fix NPE if docker:save is called with -Dfile=file-name-only.tar ([#1203](https://github.com/fabric8io/docker-maven-plugin/issues/1203)) - Fix NPE in BuildImageConfiguration ([#1200](https://github.com/fabric8io/docker-maven-plugin/issues/1200)) - Improve GZIP compression performance for docker:save ([#1205](https://github.com/fabric8io/docker-maven-plugin/issues/1205)) - Allow docker:save to attach image archive as a project artifact ([#1210](https://github.com/fabric8io/docker-maven-plugin/pull/1210)) - Use pattern to detect image name in archive loaded during build and tag with image name from the project configuration ([#1207](https://github.com/fabric8io/docker-maven-plugin/issues/1207)) - Add 'cacheFrom' option to specify images to use as cache sources ([#1132](https://github.com/fabric8io/docker-maven-plugin/issues/1132)) Renamed "nocache" to "noCache" for consistencies reason. "nocache" is still supported but deprecated and will be removed in a future version. Same is true for the global system property "docker.nocache" which is renamed to "docker.noCache" * **0.29.0** (2019-04-08) - Avoid failing docker:save when no images with build configuration are present ([#1185](https://github.com/fabric8io/docker-maven-plugin/issues/1185)) - Reintroduce minimal API-VERSION parameter in order to support docker versions below apiVersion 1.25 - docs: Correct default image naming - Proxy settings are being ignored ([#1148](https://github.com/fabric8io/docker-maven-plugin/issues/1148)) - close api version http connection ([#1152](https://github.com/fabric8io/docker-maven-plugin/issues/1152)) - Log more information when verbose=true ([#917](https://github.com/fabric8io/docker-maven-plugin/issues/917)) - Obtain container ip address from custom network for tcp/http wait - Fix http (SSL) ping with 'allowAllHosts' flag enabled - Update to jnr-unixsocket 0.22 - Enhance @sha256 digest for tags in FROM (image_name:image_tag@sha256) ([#541](https://github.com/fabric8io/docker-maven-plugin/issues/541)) - Support docker SHELL setting for runCmds ([#1157](https://github.com/fabric8io/docker-maven-plugin/issues/1157)) - Added 'autoRemove' option for running containers ([#1179](https://github.com/fabric8io/docker-maven-plugin/issues/1179)) - Added support for AWS EC2 instance roles when pushing to AWS ECR ([#1186](https://github.com/fabric8io/docker-maven-plugin/issues/1186)) - Introduce `contextDir` configuration option which would be used to specify docker build context ([#1189](https://github.com/fabric8io/docker-maven-plugin/issues/1189)) - Add support for auto-pulling multiple base image for multi stage builds ([#1057](https://github.com/fabric8io/docker-maven-plugin/issues/1057)) - Fix usage of credential helper that do not support 'version' command ([#1159](https://github.com/fabric8io/docker-maven-plugin/issues/1159)) Please note that `dockerFileDir` is now deprecated in favor of `contextDir` which also allows absolute paths to Dockerfile with `dockerFile` and it will be removed in 1.0.0. It's still supported in this release but users are suggested to migrate to `contextDir` instead. * **0.28.0** (2018-12-13) - Update to JMockit 1.43 - Compiles with Java 11 - Update to jnr-unixsocket version to 0.21 ([#1089](https://github.com/fabric8io/docker-maven-plugin/issues/1089)) - Add 'readOnly' option for docker:run cto mount container's root fs read-only ([#1125](https://github.com/fabric8io/docker-maven-plugin/issues/1125)) - Provide container properties to the wait configuration execution ([#1111](https://github.com/fabric8io/docker-maven-plugin/issues/1111)) - Allow @sha256 digest for tags in FROM ([#541](https://github.com/fabric8io/docker-maven-plugin/issues/541)) * **0.27.2** (2018-10-05) - Fix NPE regression related to volumes (again) ([#1091](https://github.com/fabric8io/docker-maven-plugin/issues/1091)) - Fix NPE when stopping containers with autoCreateCustomNetworks ([#1097](https://github.com/fabric8io/docker-maven-plugin/issues/1097)) - Smarter API version handling ([#1060](https://github.com/fabric8io/docker-maven-plugin/issues/1060)) - Fix regression when calling the credential helper for authentication, leading to an exception because of the usage of an already shutdown executor service ([#1098](https://github.com/fabric8io/docker-maven-plugin/issues/1098)) - Add support for CPU configurations with compose ([#1102](https://github.com/fabric8io/docker-maven-plugin/issues/1102)) * **0.27.1** (2018-09-28) - Fix NPE when no volume configuration is present ([#1091](https://github.com/fabric8io/docker-maven-plugin/issues/1091)) - Allow credentialhelper look up the registry without scheme prefix ([#1068](https://github.com/fabric8io/docker-maven-plugin/issues/1068)) * **0.27.0** (2018-09-26) - Jump to Java 8 as minimal Java version - Fix NPE in docker:remove-volumes when no volume configuration is given ([#1086](https://github.com/fabric8io/docker-maven-plugin/issues/1086)) - Fix NPE when no networks are configured ([#1055](https://github.com/fabric8io/docker-maven-plugin/issues/1055)) - Fix Base64 encoding for X-Registry-Auth used for Docker authentication ([#1084](https://github.com/fabric8io/docker-maven-plugin/issues/1084)) - Fix property configuration based's build detection ([#1078](https://github.com/fabric8io/docker-maven-plugin/issues/1078)) - Introduce container name patterns for naming containers ([#931](https://github.com/fabric8io/docker-maven-plugin/issues/931)) - Respect environment variables DOCKER_CONFIG, KUBECONFIG for looking up credentials ([#1083](https://github.com/fabric8io/docker-maven-plugin/issues/1083)) - Change from org.json with Gson for less restrictive licensing ([#1016](https://github.com/fabric8io/docker-maven-plugin/issues/1016)) ([#1064](https://github.com/fabric8io/docker-maven-plugin/issues/1064)) - Fix missing actions in a watch restart ([#1070](https://github.com/fabric8io/docker-maven-plugin/issues/1070)) - Fix for creating volumes with proper configuration during "docker:start" ([#986](https://github.com/fabric8io/docker-maven-plugin/issues/986)) - Fix logging failure on Windows ([#873](https://github.com/fabric8io/docker-maven-plugin/issues/873)) * **0.26.1** (2018-07-20) - Simple Dockerfile triggered also when only a single run section is given - Sample added for how to use run-java-sh in simple dockerfile mode - Allow both cred helpers and auth in Docker config ([#1041](https://github.com/fabric8io/docker-maven-plugin/issues/1041)) * **0.26.0** (2018-05-16) - Always create missing target directory for docker:save ([#1013](https://github.com/fabric8io/docker-maven-plugin/issues/1013)) - d-m-p plugins for adding extra files introduced. See documentation for more information. - Update assembly plugin to 3.1.0 ([#1021](https://github.com/fabric8io/docker-maven-plugin/issues/1021)) - Add option for regenerating certificates after starting Docker Machine ([#1019](https://github.com/fabric8io/docker-maven-plugin/issues/1019)) - Add `startPeriod` to `healthCheck` ([#961](https://github.com/fabric8io/docker-maven-plugin/issues/961)) - Unbreak setting of entrypoint in `exec` form when property mode is enabled ([#1020](https://github.com/fabric8io/docker-maven-plugin/issues/1020)) - Fix enabling of log configuration ([#1010](https://github.com/fabric8io/docker-maven-plugin/issues/1010)) - Add possibility to use `docker.imagePropertyConfiguration` with multiple images ([#1001](https://github.com/fabric8io/docker-maven-plugin/issues/1001)) - Fix network aliases management for docker-compose mode ([#1000](https://github.com/fabric8io/docker-maven-plugin/issues/1000)) * **0.25.2** (2018-04-14) - Fix for docker login issue with index.docker.io using a credential helper ([#946](https://github.com/fabric8io/docker-maven-plugin/issues/946)) * **0.25.1** (2018-04-12) - Fix regression which broke labels and env with space ([#988](https://github.com/fabric8io/docker-maven-plugin/issues/988)) - Fix and enhanced zero-config Dockerfile mode * **0.25.0** (2018-04-04) - Fix possible NPE when logging to a file and the parent directory does not exist yet ([#911](https://github.com/fabric8io/docker-maven-plugin/issues/911)) ([#940](https://github.com/fabric8io/docker-maven-plugin/issues/940)) - Change content type to "application/json" when talking to the Docker daemon ([#945](https://github.com/fabric8io/docker-maven-plugin/issues/945)) - PostStart exec breakOnError now fails fast ([#970](https://github.com/fabric8io/docker-maven-plugin/issues/970)) - Use docker.skip.tag property on push and remove ([#954](https://github.com/fabric8io/docker-maven-plugin/issues/954)) ([#869](https://github.com/fabric8io/docker-maven-plugin/issues/869)) - Property placeholders are not interpolated when they are the only thing in the XML element value ([#960](https://github.com/fabric8io/docker-maven-plugin/issues/960)) - Fix deadlock waiting on docker log pattern to match ([#767](https://github.com/fabric8io/docker-maven-plugin/issues/767)) ([#981](https://github.com/fabric8io/docker-maven-plugin/issues/981)) ([#947](https://github.com/fabric8io/docker-maven-plugin/issues/947)) - Support multiline labels and empty labels ([#968](https://github.com/fabric8io/docker-maven-plugin/issues/968)) - Handle multi line credential helper responses ([#930](https://github.com/fabric8io/docker-maven-plugin/issues/930)) - Add support for merging external properties with XML configuration ([#938](https://github.com/fabric8io/docker-maven-plugin/issues/938)) ([#948](https://github.com/fabric8io/docker-maven-plugin/issues/948)) - Allow to specify different environment variables for run and build via properties ([#386](https://github.com/fabric8io/docker-maven-plugin/issues/386)) - Add simplified configuration which picks up a plain Dockerfile automatically from `src/main/docker` ([#957](https://github.com/fabric8io/docker-maven-plugin/issues/957)) * **0.24.0** (2018-02-07) - Respect system properties for ECR authentication ([#897](https://github.com/fabric8io/docker-maven-plugin/issues/897)) - Simplified auto pull handling and moved to `imagePullPolicy` instead. - Initialize shutdown hook early to allow killing of containers when waiting for a condition ([#921](https://github.com/fabric8io/docker-maven-plugin/issues/921)) - Fix for including in assembly in archive mode when using a Dockerfile ([#916](https://github.com/fabric8io/docker-maven-plugin/issues/916)) - Fix for hanging wait on log ([#904](https://github.com/fabric8io/docker-maven-plugin/issues/904)) - Fix for credential helper which do not return a version ([#896](https://github.com/fabric8io/docker-maven-plugin/issues/896)) - Also remove tagged images when calling `docker:remove` ([#193](https://github.com/fabric8io/docker-maven-plugin/issues/193)) - Introduced a `removeMode` for selecting the images to remove - Introduced a `breakOnError` for the `postStart` and `preStop` hooks in the wait configuration ([#914](https://github.com/fabric8io/docker-maven-plugin/issues/914)) Please note that `autoPullMode` is deprecated now and the behaviour of the `autoPullMode == always` has been changed slightly so that now, it really always pulls the image from the registry. Also `removeAll` for `docker:remove` is deprecated in favor of `removeMode` (and the default mode has changed slightly). Please refer to the documentation for more information. * **0.23.0** (2017-11-04) - Support relative paths when binding volumes in `docker-compose.yml` ([#846](https://github.com/fabric8io/docker-maven-plugin/issues/846)) - Allow the session token for AWS authentication to be included in order to allow temporary security credentials provided by the AWS Security Token Service (AWS STS) to sign requests ([#883](https://github.com/fabric8io/docker-maven-plugin/issues/883)) - Add support for credential helper to authenticate against a registry ([#821](https://github.com/fabric8io/docker-maven-plugin/issues/821)) - Fix registry auth config in plugin configuration ([#858](https://github.com/fabric8io/docker-maven-plugin/issues/858)) - Preserve leading whitespace in logs ([#875](https://github.com/fabric8io/docker-maven-plugin/issues/875)) - Maven property interpolation in Dockerfiles ([#877](https://github.com/fabric8io/docker-maven-plugin/issues/877)) - Allow parameters for the log prefix ([#890](https://github.com/fabric8io/docker-maven-plugin/issues/890)) - When removing a volume don't error if the volume does not exist ([#788](https://github.com/fabric8io/docker-maven-plugin/issues/788)) - Fix warning when COPY and/or ADD with parameters are used ([#884](https://github.com/fabric8io/docker-maven-plugin/issues/884)) * **0.22.1** (2017-08-28) - Allow Docker compose version "2", too ([#829](https://github.com/fabric8io/docker-maven-plugin/issues/829)) - Allow a registry to be set programmatically ([#853](https://github.com/fabric8io/docker-maven-plugin/issues/853)) * **0.22.0** (2017-08-24) - Fix NPE when detecting cert paths ([#764](https://github.com/fabric8io/docker-maven-plugin/issues/764)) - Fix `skipDockerMachine` ([#759](https://github.com/fabric8io/docker-maven-plugin/issues/759)) - Fix property config handler to work also with dockerFile and dockerFileDir ([#790](https://github.com/fabric8io/docker-maven-plugin/issues/790)) - Fix `dockerFile` option when pointing to another Dockerfile name ([#784](https://github.com/fabric8io/docker-maven-plugin/issues/784)) - Allow comma separated list of container names in dependsOn elements ([#810](https://github.com/fabric8io/docker-maven-plugin/issues/810)) - Trim whitespace and ignore empty elements in build configuration ports, runCmds, tags, volumes ([#816](https://github.com/fabric8io/docker-maven-plugin/issues/816)) - Trim whitespace and ignore empty elements in run configuration ports ([#816](https://github.com/fabric8io/docker-maven-plugin/issues/816)) - Fix "useAllReactorProjects" in assembly ([#812](https://github.com/fabric8io/docker-maven-plugin/issues/812)) - Add ECDSA support ([#824](https://github.com/fabric8io/docker-maven-plugin/issues/824)) - Fix test failures when build under Windows ([#834](https://github.com/fabric8io/docker-maven-plugin/issues/834)) - Update dependencies to latest versions where possible * **0.21.0** (2017-05-16) - Add wait checker for checking the exit code of a container ([#498](https://github.com/fabric8io/docker-maven-plugin/issues/498)) - Check for exited container when doing wait checks ([#757](https://github.com/fabric8io/docker-maven-plugin/issues/757)) - New assembly configuration "name" for specifying the directory which holds the assembly files ([#634](https://github.com/fabric8io/docker-maven-plugin/issues/634)) - Add support for property replacement in external Dockerfiles ([#777](https://github.com/fabric8io/docker-maven-plugin/issues/777)) Please note that now filtering in an external Dockerfiles is switched on by default. This might interfere with Docker build args, so should switch filtering off with `false` in the `` configuration if you have issues with this. See also the Documentation about [Filtering](https://dmp.fabric8.io/#build-filtering) for more Details. * **0.20.1** (2017-03-29) - Tune log output for image names ([#737](https://github.com/fabric8io/docker-maven-plugin/issues/737)) - Allow image with multiple path segments ([#694](https://github.com/fabric8io/docker-maven-plugin/issues/694)) - Add support for PKCS#8 private keys in pem.key file. ([#730](https://github.com/fabric8io/docker-maven-plugin/issues/730)) - Improve resource management for certificates and keys. ([#730](https://github.com/fabric8io/docker-maven-plugin/issues/730)) - When using properties for configuration only build when `from` or `fromExt` is set ([#736](https://github.com/fabric8io/docker-maven-plugin/issues/736)) - Add new mojo "docker:save" for saving the image to a file ([#687](https://github.com/fabric8io/docker-maven-plugin/issues/687)) - Check whether a temporary tag could be removed and throw an error if not ([#725](https://github.com/fabric8io/docker-maven-plugin/issues/725)) - Allow multi line matches in log output ([#628](https://github.com/fabric8io/docker-maven-plugin/issues/628)) - Add a wait condition on a healthcheck when starting up containers ([#719](https://github.com/fabric8io/docker-maven-plugin/issues/719)) - Don't use authentication from config when no "auth" is set ([#731](https://github.com/fabric8io/docker-maven-plugin/issues/731)) * **0.20.0** (2017-02-17) - Removed `build-nofork` and `source-nofork` in favor for a more direct solution which prevents forking of the lifecycle. Please refer the documentation, chapter "Assembly" for more information about this. The experimental goals `build-nofork` and `source-nofork` have been removed again. Please use `build` and `source` directly when binding to execution phases. * **0.19.1** (2017-02-09) - Fix handling of `run` commands from properties ([#684](https://github.com/fabric8io/docker-maven-plugin/issues/684)) - Fix empty `` causing `NullPointerException` ([#693](https://github.com/fabric8io/docker-maven-plugin/issues/693)) * **0.19.0** (2017-01-03) - Better log message when waiting for URL ([#640](https://github.com/fabric8io/docker-maven-plugin/issues/640)) - Extended authentication for AWS ECR ([#663](https://github.com/fabric8io/docker-maven-plugin/issues/663)) - Add two new goals: "volume-create" and "volume-remove" for volume handling independent of images. - Support for loading from an tar archive (option ``) ([#645](https://github.com/fabric8io/docker-maven-plugin/issues/645)) - Support when both `dockerFileDir` and `dockerFile` are set and `dockerFile` is a relative path ([#624](https://github.com/fabric8io/docker-maven-plugin/issues/624)) - Fix concurrency issue when writing into log files ([#652](https://github.com/fabric8io/docker-maven-plugin/issues/652)) - Support any Docker build options ([#666](https://github.com/fabric8io/docker-maven-plugin/issues/666)) * **0.18.1** (2016-11-17) - Renamed `basedir` and `exportBasedir` in an `` configuration to `targetDir` and `exportTargetDir` since this better reflects the purpose, i.e. the target in the Docker image to which the assembly is copied. The old name is still recognized but deprecated. - Fix issue with log statements which use a single argument form - Fix bug in HTTP wait configuration when using an external property handler ([#613](https://github.com/fabric8io/docker-maven-plugin/issues/613)) - Fix NPE for "docker:log" when the container to log has already been stopped ([#612](https://github.com/fabric8io/docker-maven-plugin/issues/612)) - Allow a protocol (tcp/udp) for the specification of a port ([#610](https://github.com/fabric8io/docker-maven-plugin/issues/610)) The following variables in the assembly configuration has been renamed for consistencies sake: * `basedir` --> `targetDir` * `exportBasedir` --> `exportTargetDir` The old variable names are still accepted but will be removed for release 1.0 * **0.17.2** (2016-11-3) - Fix issues with an empty Docker config file * **0.17.1** (2016-10-28) - Add initial [Docker compose](https://dmp.fabric8.io/#docker-compose) support ([#384](https://github.com/fabric8io/docker-maven-plugin/issues/384)) - Made `docker:run` running in the foreground - Add lifecycle fork to package for `docker:build` and `docker:source` for ease of use. Introduced `docker:build-nofork` and `docker:source-nofork` - Removed lifecycle forks for all other Mojos ([#567](https://github.com/fabric8io/docker-maven-plugin/issues/567)) ([#599](https://github.com/fabric8io/docker-maven-plugin/issues/599)) - Add new option `tarLongFileMode` for the assembly configuration to avoid warning for too long files ([#591](https://github.com/fabric8io/docker-maven-plugin/issues/591)) - Add new option `tmpfs` for `` to add mount pathes for temorary file systems ([#455](https://github.com/fabric8io/docker-maven-plugin/issues/455)) - Changed `docker.image` to `docker.filter` and `` to ``. For 0.17 the lifecycle handling of the plugins has changed slightly. All forks to the _initialize_ phase have been removed since they collide with certain setups. Instead a fork to the _package_ phase has been introduced for `docker:build` and `docker:source` to make it easier for them to be consumed on the commandline (because otherwise at least `package` has to be added as goal so that the assembly could be constructed from the artifacts built). If you have these goals bound to an `` please use `build-nofork` and `source-nofork` instead, otherwise the package phase will be called twice. Also the treatment of the Maven property `docker.image` has changed. This was supposed to be used as a filter which caused a lot of confusion if people accidentally put their Docker image names into this property. Now the property has no special meaning anymore, and you can use `docker.filter` now for filtering out a specific images to build. For the same reason the top-level configuration element `` has been renamed to ``. * **0.16.9** (2016-10-23) - Removed (undocumented) property `docker.image.name` which could be used to be inserted as a `%a` specifier part in an image name. - Fixed exposing of all property and port mappings ([#583](https://github.com/fabric8io/docker-maven-plugin/issues/583)) - Fix concurrency issue on log wait ([#596](https://github.com/fabric8io/docker-maven-plugin/issues/596)) - Add Dockerfile HEALTHCHECK support ([#594](https://github.com/fabric8io/docker-maven-plugin/issues/594)) - Fix writing empty property files ([#592](https://github.com/fabric8io/docker-maven-plugin/issues/592)) * **0.16.8** (2016-10-14) - Allow multiple network links per `` element ([#558](https://github.com/fabric8io/docker-maven-plugin/issues/558)) - Fix startup of dependent containers when using links with specific container ids ([#586](https://github.com/fabric8io/docker-maven-plugin/issues/586)) * **0.16.7** (2016-10-07) - Even better logging * **0.16.6** (2016-10-07) - Fix concurrency issues when doing a watch on logs ([#574](https://github.com/fabric8io/docker-maven-plugin/issues/574)) - Break push with dedicated registry if temporary image tag already exists ([#575](https://github.com/fabric8io/docker-maven-plugin/issues/575)) - Reduce log output for the non color case when pulling images ([#568](https://github.com/fabric8io/docker-maven-plugin/issues/568)) - Add possibility to change colors in log messages - Don't print a progressbar when in batch mode (mvn -B) ([#564](https://github.com/fabric8io/docker-maven-plugin/issues/564)) - Add `exposedProperty` key to change the alias part of the exposed container properties ([#557](https://github.com/fabric8io/docker-maven-plugin/issues/557)) * **0.16.5** (2016-09-27) - Refactored Docker connection parameter detection - Added a for extended definition of base images ([#572](https://github.com/fabric8io/docker-maven-plugin/issues/572)) * **0.16.4** (2016-09-26) - Fix issue with DOCKER_HOST coming from Docker Machine - Don't pull a 'scratch' base image ([#565](https://github.com/fabric8io/docker-maven-plugin/issues/565)) - Fix handling when looking up non-existing containers ([#566](https://github.com/fabric8io/docker-maven-plugin/issues/566)) * **0.16.3** (2016-09-22) - Add 'allowAllHosts' to ping wait checker ([#559](https://github.com/fabric8io/docker-maven-plugin/issues/559)) - Allow 'stopAllContainers' also as Maven properties ([#536](https://github.com/fabric8io/docker-maven-plugin/issues/536)) - Use alias for stopping containers when naming strategy "alias" is used ([#536](https://github.com/fabric8io/docker-maven-plugin/issues/536)) - New option 'startParallel' for docker:start to speedup execution ([#531](https://github.com/fabric8io/docker-maven-plugin/issues/531)) - Tuned detection of docker host connection parameters to be more extensible * **0.16.2** (2016-09-15) - Fixed naming of 'buildArgs' for `docker:build` (was `args` formerly) - Experimental Support for 'Docker for Windows' ([#523](https://github.com/fabric8io/docker-maven-plugin/issues/523)) - Remove versions from custom lifecycle deps ([#539](https://github.com/fabric8io/docker-maven-plugin/issues/539)) - Fix extra new line in logoutput ([#538](https://github.com/fabric8io/docker-maven-plugin/issues/538)) * **0.15.16** (2016-08-03) - Run 'stopContainer' in a Future to short circuit extra waiting ([#518](https://github.com/fabric8io/docker-maven-plugin/issues/518)) - Don't pass `docker.buildArg` values that are empty ([#529](https://github.com/fabric8io/docker-maven-plugin/issues/529)) - Add new implicit generated properties `docker.container..net..ip` when custom networks are used ([#533](https://github.com/fabric8io/docker-maven-plugin/issues/533)) * **0.15.14** (2016-07-29) - Pattern match fix for multiline log output. Related to ([#259](https://github.com/fabric8io/docker-maven-plugin/issues/259)) * **0.15.13** (2016-07-29) - Add for running containers in special security contexts ([#524](https://github.com/fabric8io/docker-maven-plugin/issues/524)) - Add support for multiples network aliases ([#466](https://github.com/fabric8io/docker-maven-plugin/issues/466)) * **0.15.12** (2016-07-25) - API and documentation updates * **0.15.11** (2016-07-20) - Invoke the `initialize` phase before docker goals ([#315](https://github.com/fabric8io/docker-maven-plugin/issues/315)) - Allow images to only be pulled once per build (useful for reactor projects) ([#504](https://github.com/fabric8io/docker-maven-plugin/issues/504)) - Allow retry of pushing a docker image in case of a 500 error ([#508](https://github.com/fabric8io/docker-maven-plugin/issues/508)) - Add "ulimits" to run-configuration ([#484](https://github.com/fabric8io/docker-maven-plugin/issues/484)) * **0.15.10** (2016-07-19) - Don't do redirect when waiting on an HTTP port ([#499](https://github.com/fabric8io/docker-maven-plugin/issues/499)) - Removed the container fetch limit of 100 and optimized getting containers by name and image ([#513](https://github.com/fabric8io/docker-maven-plugin/issues/513)) * **0.15.9** (2016-06-28) - Fixed issue when target directory does not exist yet ([#497](https://github.com/fabric8io/docker-maven-plugin/issues/497)) * **0.15.8** (2016-06-27) - Removed image configuration caching ([#495](https://github.com/fabric8io/docker-maven-plugin/issues/495)) - Fix for tcp wait when used with Docker for Mac ([#430](https://github.com/fabric8io/docker-maven-plugin/issues/430)) - Add warning when assembly is empty when watching a Docker image ([#490](https://github.com/fabric8io/docker-maven-plugin/issues/490)) - Add `docker.skip.build`, `docker.skip.run`, `docker.skip.push` properties and renamed `docker.skipTags` to `docker.skip.tag` ([#483](https://github.com/fabric8io/docker-maven-plugin/issues/483)) - Reverted jansi back to version 1.11 because of [this issue](https://github.com/fusesource/jansi/issues/58) - Add new assembly config options `permissions` for fine tuning permissions in the docker.tar ([#477](https://github.com/fabric8io/docker-maven-plugin/issues/477)). Deprecated `ignorePermissions` in favor of a `ignore` - Add auto creation of custom networks if the option `autoCreateCustomNetwork` is set ([#482](https://github.com/fabric8io/docker-maven-plugin/issues/482)) - Support for docker machine added ([#481](https://github.com/fabric8io/docker-maven-plugin/issues/481)) * **0.15.7** (2016-06-09) - Add support for '.maven-dockerinclude' for including certain files in plain Dockerfile build ([#471](https://github.com/fabric8io/docker-maven-plugin/issues/471)) - Add support for placeholders in image names. - Expose container id as Maven property `docker.container..id` ([#412](https://github.com/fabric8io/docker-maven-plugin/issues/412)) - Fix broken link in documentation ([#468](https://github.com/fabric8io/docker-maven-plugin/issues/468)) * **0.15.4** (2016-06-03) - Update dependencies: Apache HttpClient 4.5.2, JMockit 1.23, ... - Fix read-only bindings ([#462](https://github.com/fabric8io/docker-maven-plugin/issues/462)) - Add 'shmSize' as option to the build config ([#463](https://github.com/fabric8io/docker-maven-plugin/issues/463)) - Fixed issue with `memory` and ` * **0.15.3** (2016-05-27) - Add duration information when pulling, building and pushing images ([#313](https://github.com/fabric8io/docker-maven-plugin/issues/313)) - Fixed logging to always use format strings ([#457](https://github.com/fabric8io/docker-maven-plugin/issues/457)) - Allow extended image names ([#459](https://github.com/fabric8io/docker-maven-plugin/issues/459)) * **0.15.2** (2016-05-19) - More robust response stream parsing ([#436](https://github.com/fabric8io/docker-maven-plugin/issues/436)) - Add `docker.dockerFileDir` and `docker.dockerFile` to the properties configuration provider. ([#438](https://github.com/fabric8io/docker-maven-plugin/issues/438)) - Fix splitting of bind volumes for Windows pathes ([#443](https://github.com/fabric8io/docker-maven-plugin/issues/443)) - Add new build config option `user` for switching the user at the end of the Dockerfile. `docker.user` can be used for the properties configuration provider ([#441](https://github.com/fabric8io/docker-maven-plugin/issues/441)) - Include dot dirs when creating the build tar ([#446](https://github.com/fabric8io/docker-maven-plugin/issues/446)) - Fix property handler with wait config but empty tcp wait connection ([#451](https://github.com/fabric8io/docker-maven-plugin/issues/451)) * **0.15.1** (2016-05-03) - Fix push / pull progress bar ([#91](https://github.com/fabric8io/docker-maven-plugin/issues/91)) - Allow empty environment variable ([#434](https://github.com/fabric8io/docker-maven-plugin/issues/434)) - Async log request get now their own HTTP client ([#344](https://github.com/fabric8io/docker-maven-plugin/issues/344)) ([#259](https://github.com/fabric8io/docker-maven-plugin/issues/259)) * **0.15.0** (2016-04-27) - Be more conservative when no "warnings" are returned on create ([#407](https://github.com/fabric8io/docker-maven-plugin/issues/407)) - Fix parsing of timestamps with numeric timezone ([#410](https://github.com/fabric8io/docker-maven-plugin/issues/410)) - Validate image names to fit Docker conventions ([#423](https://github.com/fabric8io/docker-maven-plugin/issues/423)) ([#419](https://github.com/fabric8io/docker-maven-plugin/issues/419)) - Add support for builds args in external Dockerfiles ([#334](https://github.com/fabric8io/docker-maven-plugin/issues/334)) - Move `dockerFileDir` to topLevel `` and introduced `dockerFile` directive `build>assembly>dockerFileDir` is now deprecated and will be removed. - Add new packaging "docker" (build + run), "docker-build" (build only) and "docker-tar" (creating source) ([#433](https://github.com/fabric8io/docker-maven-plugin/issues/433)) - Add `docker:run` as an alias to `docker:start` - Expose certain container properties also as Maven properties. By default the format is `docker.container..ip` for the internal IP address of container with alias ``. ([#198](https://github.com/fabric8io/docker-maven-plugin/issues/198)) * **0.14.2** - Introduce a mode `try` for `` so that an image gets removed if not being still used. This is the default now, which should be close enough to `true` (except that it won't fail the build when the image couldn't be removed) ([#401](https://github.com/fabric8io/docker-maven-plugin/issues/401)) * **0.14.1** - First (test) release performed with a fabric8 CD pipeline. No new features. * **0.14.0** - Add support for Docker network and `host`, `bridge` and `container` network modes ([#335](https://github.com/fabric8io/docker-maven-plugin/issues/335)) - Add support for older Maven versions, minimum required version is now 3.0.5 ([#290](https://github.com/fabric8io/docker-maven-plugin/issues/290)) - Update to maven-assembly-plugin 2.6 which fixes issue with line endings on windows ([#127](https://github.com/fabric8io/docker-maven-plugin/issues/127)) - Disabled color output on Windows because ANSI emulation can't be enabled in Maven's sl4j logger which caches system out/err - Moved to [fabric8io](https://github.com/orgs/fabric8io/dashboard) as GitHub organization which implies also changes in the maven coordinates (Maven group-id is now **io.fabric8**) - Fix wait section in samples ([#385](https://github.com/fabric8io/docker-maven-plugin/issues/385)) - Add logging configuration to property handler - Add support for a logging driver ([#379](https://github.com/fabric8io/docker-maven-plugin/issues/379)) With version `0.14.0` this plugin moved to the [fabric8](http://fabric8.io) community in order to provide even better services. This include a change in the Maven coordinates. I.e. the Maven group id is now **io.fabric8** (formerly: "org.jolokia"). Please adapt your pom files accordingly. * **0.13.9** - Check also registry stored with an `https` prefix ([#367](https://github.com/fabric8io/docker-maven-plugin/issues/367)) - Don't stop containers not started by the project during parallel reactor builds ([#372](https://github.com/fabric8io/docker-maven-plugin/issues/372)) * **0.13.8** - Add option `nocache` to build configuration ([#348](https://github.com/fabric8io/docker-maven-plugin/issues/348)) - Add system property `docker.nocache` to disable build caching globally ([#349](https://github.com/fabric8io/docker-maven-plugin/issues/349)) - Add support for '.maven-dockerignore' for excluding certain files in plain Dockerfile build ([#362](https://github.com/fabric8io/docker-maven-plugin/issues/362)) - If naming strategy is "alias" stop only the container with the given alias with `docker:stop` ([#359](https://github.com/fabric8io/docker-maven-plugin/issues/359)) - Fix that containers without d-m-p label where still stopped - Add support for OpenShift login (use `-DuseOpenShiftAuth` for enabling this) ([#350](https://github.com/fabric8io/docker-maven-plugin/issues/350)) - Add support for dedicated pull and push registry configuration respectively ([#351](https://github.com/fabric8io/docker-maven-plugin/issues/351)) * **0.13.7** - Fix default for "cleanup" in build configuration to `true` (as documented) ([#338](https://github.com/fabric8io/docker-maven-plugin/issues/338)) - Fix dynamic host property update in port mapping ([#323](https://github.com/fabric8io/docker-maven-plugin/issues/323)) - New goal 'docker:source' for attaching a Docker tar archive to the Maven project with an classifier "docker-" ([#311](https://github.com/fabric8io/docker-maven-plugin/issues/311)) - Be more careful with chowning the user when is used in an assembly ([#336](https://github.com/fabric8io/docker-maven-plugin/issues/336)) - Move VOLUME to the end of the Dockerfile to allow initialization via RUN commands ([#341](https://github.com/fabric8io/docker-maven-plugin/issues/341)) - Allow multiple configurations with different Docker hosts again ([#320](https://github.com/fabric8io/docker-maven-plugin/issues/320)) - `docker:start` blocks now only when system property docker.follow is given ([#249](https://github.com/fabric8io/docker-maven-plugin/issues/249)) - `docker:stop` only stops containers started by this plugin by default ([#87](https://github.com/fabric8io/docker-maven-plugin/issues/87)) - Lookup `~/.docker/config.json` for registry credentials as fallback ([#147](https://github.com/fabric8io/docker-maven-plugin/issues/147)) * **0.13.6** - Don't use user from image when pulling base images ([#147](https://github.com/fabric8io/docker-maven-plugin/issues/147)) - Add a new assembly descriptor reference `hawt-app` for using assemblies created by [hawt-app](https://github.com/fabric8io/fabric8/tree/master/hawt-app-maven-plugin) * **0.13.5** - Improvements for `docker:watch` ([#288](https://github.com/fabric8io/docker-maven-plugin/issues/288)) - Add parameter `kill` to `` configuration for waiting before sending SIGKILL when stopping containers ([#293](https://github.com/fabric8io/docker-maven-plugin/issues/293)) - Add `file` for `` to store the logout put in a file. Use `docker.logStdout` to show logs nevertheless to stdout ([#287](https://github.com/fabric8io/docker-maven-plugin/issues/287)) - Support `watchMode == copy` for copying changed assembly files into a running container ([#268](https://github.com/fabric8io/docker-maven-plugin/issues/268)) - Add a `target/classpath` file to the assembly as `classpath` for `artifact-with-dependencies` predefined assembly descriptor ([#283](https://github.com/fabric8io/docker-maven-plugin/issues/283)) - Disable Apache HTTP Client retry in WaitUtil ([#297](https://github.com/fabric8io/docker-maven-plugin/issues/297)) * **0.13.4** - Support explicit exec arguments for `start.cmd` and `start.entrypoint`. ([#253](https://github.com/fabric8io/docker-maven-plugin/issues/253)) - Fix processing of split chunked JSON responses ([#259](https://github.com/fabric8io/docker-maven-plugin/issues/259)) - Fix for default registry handling. Again and again. ([#261](https://github.com/fabric8io/docker-maven-plugin/issues/261)) - Allow `runCmds` to be compressed into a single command with the build config option `optimise`. ([#263](https://github.com/fabric8io/docker-maven-plugin/issues/263)) - Proper error message when default timeout is hit while waiting ([#274](https://github.com/fabric8io/docker-maven-plugin/issues/274)) - Add proper error message when docker host URL is malformed ([#277](https://github.com/fabric8io/docker-maven-plugin/issues/277)) - If no wait condition is given in wait continue immediately ([#276](https://github.com/fabric8io/docker-maven-plugin/issues/276)) - Add logic to specify exec commands during postStart and preStop ([#272](https://github.com/fabric8io/docker-maven-plugin/issues/272)) - Fixed docker:watch bug when watching on plain files * **0.13.3** - Allow dangling images to be cleaned up after build ([#20](https://github.com/fabric8io/docker-maven-plugin/issues/20)) - Adapt order of WORKDIR and RUN when building images ([#222](https://github.com/fabric8io/docker-maven-plugin/issues/222)) - Allow 'build' and/or 'run' configuration to be skipped ([#207](https://github.com/fabric8io/docker-maven-plugin/issues/207)) - Refactored to use 'inspect' instead of 'list' for checking the existence of an image ([#230](https://github.com/fabric8io/docker-maven-plugin/issues/230)) - Refactored ApacheHttpClientDelegate to avoid leaking connections ([#232](https://github.com/fabric8io/docker-maven-plugin/issues/232)) - Allow empty `build` or `assembly` elements ([#214](https://github.com/fabric8io/docker-maven-plugin/issues/214)) ([#236](https://github.com/fabric8io/docker-maven-plugin/issues/236)) - Add new configuration parameter 'maxConnections' to allow to specify the number of parallel connections to the Docker Host. Default: 100 ([#254](https://github.com/fabric8io/docker-maven-plugin/issues/254)) - Allow multiple containers of the same image to be linked ([#182](https://github.com/fabric8io/docker-maven-plugin/issues/182)) - HTTP method and status code can be specified when waiting on an HTTP URL ([#258](https://github.com/fabric8io/docker-maven-plugin/issues/258)) - Introduced global `portPropertyFile` setting ([#90](https://github.com/fabric8io/docker-maven-plugin/issues/90)) - Allow the container's host ip to be bound to a maven property and exported * **0.13.2** - "run" directives can be added to the Dockerfile ([#191](https://github.com/fabric8io/docker-maven-plugin/issues/191)) - Support user information in wait URL ([#211](https://github.com/fabric8io/docker-maven-plugin/issues/211)) - Stop started container in case of an error during startup ([#217](https://github.com/fabric8io/docker-maven-plugin/issues/217)) - Allow linking to external containers ([#195](https://github.com/fabric8io/docker-maven-plugin/issues/195)) - Allow volume mounting from external containers ([#73](https://github.com/fabric8io/docker-maven-plugin/issues/73)) * **0.13.1** - Allow autoPull to be forced on docker:build and docker:start ([#96](https://github.com/fabric8io/docker-maven-plugin/issues/96)) - Respect username when looking up credentials for a Docker registry ([#174](https://github.com/fabric8io/docker-maven-plugin/issues/174)) - Add "force=1" to push for Fedora/CentOs images allowing to push to docker hub Note that the default registry has been changed to `docker.io` as docker hub doesn't use `registry.hub.docker.com` as the default registry and refused to authenticate against this registry. For backward compatibility reasons `registry.hub.docker.com`, `index.docker.io` and `docker.io` can be used as a server id in `~/.m2/settings.xml` for the default credentials for pushing without registry to Docker hub. * **0.13.0** - Add `docker:watch` ([#187](https://github.com/fabric8io/docker-maven-plugin/issues/187)) - Allow `extraHosts` IPs to be resolved at runtime ([#196](https://github.com/fabric8io/docker-maven-plugin/issues/196)) - Add `workDir` as configuration option to `` ([#204](https://github.com/fabric8io/docker-maven-plugin/issues/204)) - Fix problem with log output and wait ([#200](https://github.com/fabric8io/docker-maven-plugin/issues/200)) - Don't verify SSL server certificates if `DOCKER_TLS_VERIFY` is not set ([#192](https://github.com/fabric8io/docker-maven-plugin/issues/192)) - For bind path on Windows machines ([#188](https://github.com/fabric8io/docker-maven-plugin/issues/188)) - No 'from' required when using a Dockerfile ([#201](https://github.com/fabric8io/docker-maven-plugin/issues/201)) - Support for LABEL for build and run. Note that since version 0.13.0 this plugin requires Docker API version v1.17 or later in order to support labels. The watch feature has changed: Instead of using paramters like `docker.watch` or `docker.watch.interval` for `docker:start` a dedicated `docker:watch` has been introduced. Also the `...` configuration has been moved one level up so that `` and `` are on the same level. Please refer to the [manual](manual.md#watching-for-image-changes) for an in depth explanation of the much enhanced watch functionality. * **0.12.0** - Allow CMD and ENTRYPOINT with shell and exec arguments ([#130](https://github.com/fabric8io/docker-maven-plugin/issues/130)) ([#149](https://github.com/fabric8io/docker-maven-plugin/issues/149)) - Unix Socket support ([#179](https://github.com/fabric8io/docker-maven-plugin/issues/179)) - Add a new parameter 'skipTags' for avoiding configured tagging of images ([#145](https://github.com/fabric8io/docker-maven-plugin/issues/145)) - Break build if log check or URL check runs into a timeout ([#173](https://github.com/fabric8io/docker-maven-plugin/issues/173)) Please note that for consistencies sake `` has been renamed to `` which contains inner elements to match better the equivalent Dockerfile argument. The update should be trivial and easy to spot since a build will croak immediately. The old format ````xml java -jar /server.jar ```` becomes now ````xml java -jar /server.jar ```` or ````xml java -jar /server.jar ```` depending on whether you prefer the `exec` or `shell` form. * **0.11.5** - Fix problem with http:// URLs when a CERT path is set - Fix warnings when parsing a pull response - Add a new parameter 'docker.follow' which makes a `docker:start` blocking until the CTRL-C is pressed ([#176](https://github.com/fabric8io/docker-maven-plugin/issues/176)) - Add a `user` parameter to the assembly configuration so that the added files are created for this user - Fix problem when creating intermediate archive for collecting assembly files introduced with #139. The container can be now set with "mode" in the assembly configuration with the possible values `dir`, `tar`, `tgz` and `zip` ([#171](https://github.com/fabric8io/docker-maven-plugin/issues/171)) - Workaround Docker problem when using an implicit registry `index.docker.io` when no registry is explicitly given. - Fixed references to docker hub in documentation ([#169](https://github.com/fabric8io/docker-maven-plugin/issues/169)) - Fixed registry authentication lookup ([#146](https://github.com/fabric8io/docker-maven-plugin/issues/146)) * **0.11.4** - Fixed documentation for available properties - Changed property `docker.assembly.exportBase` to `docker.assembly.exportBaseDir` ([#164](https://github.com/fabric8io/docker-maven-plugin/issues/164)) - Changed default behaviour of `exportBaseDir` (true if no base image used with `from`, false otherwise) - Fix log messages getting cut off in the build ([#163](https://github.com/fabric8io/docker-maven-plugin/issues/163)) - Allow system properties to overwrite dynamic port mapping ([#161](https://github.com/fabric8io/docker-maven-plugin/issues/161)) - Fix for empty authentication when pushing to registries ([#102](https://github.com/fabric8io/docker-maven-plugin/issues/102)) - Added watch mode for images with `-Ddocker.watch` ([#141](https://github.com/fabric8io/docker-maven-plugin/issues/141)) - Added support for inline assemblies (#157, #158) - Add support for variable substitution is environment declarations ([#137](https://github.com/fabric8io/docker-maven-plugin/issues/137)) - Use Tar archive as intermediate container when creating image ([#139](https://github.com/fabric8io/docker-maven-plugin/issues/139)) - Better error handling for Docker errors wrapped in JSON response only ([#167](https://github.com/fabric8io/docker-maven-plugin/issues/167)) * **0.11.3** - Add support for removeVolumes in `docker:stop` configuration ([#120](https://github.com/fabric8io/docker-maven-plugin/issues/120)) - Add support for setting a custom maintainer in images ([#117](https://github.com/fabric8io/docker-maven-plugin/issues/117)) - Allow containers to be named using `alias` when started ([#48](https://github.com/fabric8io/docker-maven-plugin/issues/48)) - Add new global property 'docker.verbose' for switching verbose image build output ([#36](https://github.com/fabric8io/docker-maven-plugin/issues/36)) - Add support for environment variables specified in a property file ([#128](https://github.com/fabric8io/docker-maven-plugin/issues/128)) - Documentation improvements (#107, #121) - Allow to use a dockerFileDir without any assembly * **0.11.2** - Fix maven parse error when specifying restart policy ([#99](https://github.com/fabric8io/docker-maven-plugin/issues/99)) - Allow host names to be used in port bindings ([#101](https://github.com/fabric8io/docker-maven-plugin/issues/101)) - Add support for tagging at build and push time ([#104](https://github.com/fabric8io/docker-maven-plugin/issues/104)) - Use correct output dir during multi-project builds ([#97](https://github.com/fabric8io/docker-maven-plugin/issues/97)) - `descriptor` and `descriptorRef` in the assembly configuration are now optional ([#66](https://github.com/fabric8io/docker-maven-plugin/issues/66)) - Fix NPE when filtering enabled during assembly creation ([#82](https://github.com/fabric8io/docker-maven-plugin/issues/82)) - Allow `${project.build.finalName}` to be overridden when using a pre-packaged assembly descriptor for artifacts ([#111](https://github.com/fabric8io/docker-maven-plugin/issues/111)) * **0.11.1** - Add support for binding UDP ports ([#83](https://github.com/fabric8io/docker-maven-plugin/issues/83)) - "Entrypoint" supports now arguments ([#84](https://github.com/fabric8io/docker-maven-plugin/issues/84)) - Fix basedir for multi module projects ([#89](https://github.com/fabric8io/docker-maven-plugin/issues/89)) - Pull base images before building when "autoPull" is switched on (#76, #77, #88) - Fix for stopping containers without tag ([#86](https://github.com/fabric8io/docker-maven-plugin/issues/86)) * **0.11.0** - Add support for binding/exporting containers during startup ([#55](https://github.com/fabric8io/docker-maven-plugin/issues/55)) - Provide better control of the build assembly configuration. In addition, the plugin will now search for assembly descriptors in `src/main/docker`. This default can be overridden via the global configuration option `sourceDirectory`. - An external `Dockerfile` can now be specified to build an image. - When "creating" containers they get now all host configuration instead of during "start". This is the default behaviour since v1.15 while the older variant where the host configuration is fed into the "start" call is deprecated and will go away. - Allow selecting the API version with the configuration "apiVersion". Default and minimum API version is now "v1.15" - A registry can be specified as system property `docker.registry` or environment variable `DOCKER_REGISTRY` ([#26](https://github.com/fabric8io/docker-maven-plugin/issues/26)) - Add new wait parameter `shutdown` which allows to specify the amount of time to wait between stopping a container and removing it ([#54](https://github.com/fabric8io/docker-maven-plugin/issues/54)) Please note, that the syntax for binding volumes from another container has changed slightly in 0.10.6. See "[Volume binding](manual.md#volume-binding)" for details but in short: ````xml data fabric8/demo .... ```` becomes ````xml data fabric8/demo .... ```` The syntax for specifying the build assembly configuration has also changed. See "[Build Assembly] (manual.md#build-assembly)" for details but in short: ````xml ... /export src/main/docker/assembly.xml ```` becomes ````xml ... /export assembly.xml ```` * **0.10.5** - Add hooks for external configurations - Add property based configuration for images ([#42](https://github.com/fabric8io/docker-maven-plugin/issues/42)) - Add new goal `docker:logs` for showing logs of configured containers ([#49](https://github.com/fabric8io/docker-maven-plugin/issues/49)) - Support for showing logs during `docker:start` ([#8](https://github.com/fabric8io/docker-maven-plugin/issues/8)) - Use `COPY` instead of `ADD` when putting a Maven assembly into the container ([#53](https://github.com/fabric8io/docker-maven-plugin/issues/53)) - If `exportDir` is `/` then do not actually export (since it doesn't make much sense) (see #62) * **0.10.4** - Restructured and updated documentation - Fixed push issue when using a private registry ([#40](https://github.com/fabric8io/docker-maven-plugin/issues/40)) - Add support for binding to an arbitrary host IP ([#39](https://github.com/fabric8io/docker-maven-plugin/issues/39)) * **0.10.3** - Added "remove" goal for cleaning up images - Allow "stop" also as standalone goal for stopping all managed builds * **0.10.2** - Support for SSL Authentication with Docker 1.3. Plugin will respect `DOCKER_CERT_PATH` with fallback to `~/.docker/`. The plugin configuration `certPath` can be used, too and has the highest priority. - Getting rid of UniRest, using [Apache HttpComponents](http://hc.apache.org/) exclusively for contacting the Docker host. - Support for linking of containers (see the configuration in the [shootout-docker-maven](https://github.com/fabric8io/shootout-docker-maven/blob/master/pom.xml) POM) Images can be specified in any order, the plugin takes care of the right startup order when running containers. - Support for waiting on a container's log output before continuing ## 0.9.x Series Original configuration syntax (as described in the old [README](readme-0.9.x.md)) * **0.9.12** - Fixed push issue when using a private registry ([#40](https://github.com/fabric8io/docker-maven-plugin/issues/40)) * **0.9.11** - Support for SSL Authentication with Docker 1.3. Plugin will respect `DOCKER_CERT_PATH` with fallback to `~/.docker/`. The plugin configuration `certPath` can be used, too and has the highest priority. ================================================ FILE: doc/ci-docs.sh ================================================ echo =========================================== echo Deploying docker-maven-plugin documentation echo =========================================== mvn -Pdoc-html && \ mvn -Pdoc-pdf && \ git clone -b gh-pages git@github.com:fabric8io/docker-maven-plugin.git gh-pages && \ cp -rv target/generated-docs/* gh-pages/ && \ cd gh-pages && \ mv index.pdf docker-maven-plugin.pdf && \ git add --ignore-errors * && \ git commit -m "generated documentation" && \ git push origin gh-pages && \ cd .. && \ rm -rf gh-pages target ================================================ FILE: doc/examples.md ================================================ ## Examples This plugin comes with some commented examples in the `samples/` directory: ### Jolokia Demo [data-jolokia](https://github.com/fabric8io/docker-maven-plugin/tree/master/samples/data-jolokia) is a setup for testing the [Jolokia](http://www.jolokia.org) HTTP-JMX bridge in a tomcat. It uses a Docker data container which is linked into the Tomcat container and contains the WAR files to deploy. There are two flavor of tests * One with two image where a (almost naked) data container with the war file is created and then mounted into the server image during startup before the integration test. * When using the profile `-Pmerge` then a single image with Tomcat and the dependent war files is created. During startup of a container from the created image, a deploy script will link over the war files into Tomat so that they are automatically deployed. For running the tests call ```bash # Use two ("data" and "server") connected containers mvn clean install # Use a single image with tomcat and data: mvn -Pmerge clean install # Use a property based configuration: mvn -Pprops clean install ``` The sever used is by default Tomcat 7. This server can easily be changed with the system properties `server.name` and `server.version`. The following variants are available: * For `server.name=tomcat` the `server.version` can be 3.3, 4.0, 5.5, 6.0, 7.0 or 8.0 * For `server.name=jetty` the `server.version` can be 4, 5, 6, 7, 8 or 9 Example: ```bash mvn -Dserver.name=jetty -Dserver.version=9 clean install ``` In addition to running the integration test with building images, starting containers, running tests and stopping containers one can also only start the containers: ```bash mvn docker:start ``` In order to get the dynamically exposed port, use `docker ps`. You can connect to the Jolokia agent inside the container then with an URL like `http://localhost:http://localhost:49171/jolokia` to the Agent. For stopping the server simply call ```bash mvn docker:stop ``` ### Cargo Demo [cargo-jolokia](https://github.com/fabric8io/docker-maven-plugin/tree/master/samples/cargo-jolokia) will use Docker to start a Tomcat 7 server with dynamic port mapping, which is used for remote deployment via [Cargo](https://codehaus-cargo.github.io/cargo/Maven2+plugin.html) and running the integration tests. ### docker-maven-plugin Shootout In order to help in the decision, which plugin to use, there is a sample project [rhuss/shootout-docker-maven](https://github.com/rhuss/shootout-docker-maven), which has more complex sample project involving two images: * Vanilla PostgreSQL 9 Image * HTTP Request Logging Service - MicroService with embedded Tomcat - DB Schema is created during startup via [Flyway](http://flywaydb.org/) * PostgreSQL container is connected via a Docker 'link' * Simple integration test which exercises the service The different plugins can be enabled with different Maven profiles, the one for this plugin is called `fabric8io` (and the others `wouterd`, `alexec` and `spotify`). For more information please look over there. ================================================ FILE: doc/howto-release.md ================================================ # Release instructions ## Preparation * Increase version numbers in the poms below samples/ (they are not automatically updated) ``` cd samples mvn versions:set -DgenerateBackupPoms=false -DnewVersion=0.15.4 ``` * Run "update_issue_links.sh" in "doc/" * Check into Git, push, create PR and apply ## Building and deploying * Run the build over the fabric8 CD Pipeline or in the _classic_ way: ``` mvn -Dmaven.repo.local=/tmp/clean-repo -DdevelopmentVersion=0.23-SNAPSHOT -DreleaseVersion=0.23.0 -Dtag=v0.23.0 -Prelease release:prepare mvn -Dmaven.repo.local=/tmp/clean-repo -DdevelopmentVersion=0.23-SNAPSHOT -DreleaseVersion=0.23.0 -Dtag=v0.23.0 -Prelease release:perform ``` and then push to Maven central manually via https://oss.sonatype.org/ ## Update from upstream ``` git co master git pull upstream master git rebase upstream/master ``` ## After the build * Set sample version back to the snapshot version ``` mvn versions:set -DgenerateBackupPoms=false -DnewVersion=0.15-SNAPSHOT ``` * Check-In and create PR ## Update documentation * Update branch `dmp.fabric8.io` with the exact version of the plugin build and push it to upstream (https://github.com/fabric8io/docker-maven-plugin) ``` git fetch -u upstream --tags git co dmp.fabric8.io git merge v0.19.0 git push -u upstream dmp.fabric8.io ``` * The docs will be then build by `circleci.com` ================================================ FILE: doc/integration-tests.md ================================================ # Integration Testing This document currently only holds some ideas of how and what to integration test this plugin ### Registry Handling * Specify registry via environment variable, global configuration, as image configuration or with name * Test that `autoPull` works for `docker:start` * Check that push works with the registry. Also check, that no temporary docker images names (which needs to be created before pushing) are left over. ================================================ FILE: doc/intro.md ================================================ ## Introduction It focuses on two major aspects: * **Building** and **pushing** Docker images which contain build artifacts * **Starting** and **stopping** Docker containers for integration testing and development Docker *images* are the central entity which can be configured. Containers, on the other hand, are more or less volatile. They are created and destroyed on the fly from the configured images and are completely managed internally. ### Building docker images One purpose of this plugin is to create docker images holding the actual application. This is done with the `docker:build` goal. It is easy to include build artifacts and their dependencies into an image. Therefore, this plugin uses the [assembly descriptor format](http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html) from the [maven-assembly-plugin](http://maven.apache.org/plugins/maven-assembly-plugin/) to specify the content which will be added from a sub-directory in the image (`/maven` by default). Images that are built with this plugin can be pushed to public or private Docker registries with `docker:push`. ### Running containers With this plugin it is possible to run completely isolated integration tests so you don't need to take care of shared resources. Ports can be mapped dynamically and made available as Maven properties to your integration test code. Multiple containers can be managed at once, which can be linked together or share data via volumes. Containers are created and started with the `docker:start` goal and stopped and destroyed with the `docker:stop` goal. For integration tests, both goals are typically bound to the `pre-integration-test` and `post-integration-test` phase, respectively. It is recommended to use the [`maven-failsafe-plugin`](http://maven.apache.org/surefire/maven-failsafe-plugin/) for integration testing in order to stop the docker container even when the tests fail. For proper isolation, container exposed ports can be dynamically and flexibly mapped to localhost ports. It is easy to specify a Maven property which will be filled in with a dynamically assigned port after a container has been started. This can then be used as a parameter for integration tests to connect to the application. ### Configuration The plugin configuration contains a *general part* and a list of *image-specific* configurations, one for each image. The general part contains global configuration like the Docker URL or the path to the SSL certificates for communication with the Docker Host. Then, each specific image configuration has three parts: * A general image part containing the image's name and alias. * A `` configuration specifying how images are built. * A `` configuration describing how containers should be created and started. The `` and `` parts are optional and can be omitted. Let's look at a plugin configuration example: ````xml service fabric8/docker-demo:${project.version} java:8 docker-assembly.xml 8080 java -jar /maven/service.jar tomcat.port:8080 http://localhost:${tomcat.port}/access database:db database postgres:9 database system is ready to accept connections ```` Here, two images are specified. One is the official PostgreSQL 9 image from Docker Hub, which internally is referenced as "*database*" (``). It only has a `` section which declares that the startup should wait until the given text pattern is matched in the log output. Next is a "*service*" image, which is specified in the `` section. It creates an image which has artifacts and dependencies in the `/maven` directory (and which are specified with an assembly descriptor). Additionally it specifies the startup command for the container, which in this example fires up a microservice from a jar file copied over via the assembly descriptor. It also exposes port 8080. In the `` section this port is dynamically mapped to a dynamically chosen port, and then assigned to the Maven property `${tomcat.port}`. This property could be used, for example, by an integration test to access this microservice. An important part is the `` section which indicates that the image with the alias of "*database*" is linked into the "*service*" container, which can access the internal ports in the usual Docker way (via environment variables prefixed with `DB_`). Images can be specified in any order and the plugin will take care of the proper startup order (and will bail out if it detects circular dependencies). ### Other highlights Some other highlights in random order (and not complete): * Auto pulling of images (with a progress indicator) * Waiting for a container to startup based on time, the reachability of an URL, or a pattern in the log output * Support for SSL authentication (since Docker 1.3) * Specification of encrypted registry passwords for push and pull in `~/.m2/settings.xml` (i.e., outside the `pom.xml`) * Color output ;-) ### Why another Maven Plugin ? If you search on GitHub you will find a whole cosmos of Maven Docker plugins (As of November 2014: 12 (!) plugins which 4 actively maintained). On the one hand, variety is a good thing, but on the other hand for users it is hard to decide which one to choose. So, you might wonder why you should choose this one. There s a dedicated [shootout project](https://github.com/fabric8io/shootout-docker-maven) which compares the four most active plugins. It contains a simple demo project with a database and a microservice image, along with an integration test. Each plugin is configured to create images and run the integration test (if possible). Although it might be a bit biased, it can be useful for figuring out which plugin suits you best. The high-level design goals and initial motivation for this plugin are: * A flexible, **dynamic port mapping** from container to host ports so that truly isolated builds could be made. This should work on indirect setups with VMs like [boot2docker](https://github.com/boot2docker/boot2docker) or [docker-machine](https://docs.docker.com/machine/) for running on OS X/Windows. * It should be possible to **pull images** on the fly to get self-contained and repeatable builds with the only requirement to have Docker installed. * The configuration of the plugin should be **simple**, since developers don't want to be forced to dive into specific Docker details only to start a container. So, only a handful options should be exposed, which needs not necessarily map directly to docker config setup. * There should be as **few dependencies** as possible for this plugin. So it does *not* use the Java Docker API [docker-java](https://github.com/docker-java/docker-java) which is external to docker and has a different lifecycle than Docker's [remote API](http://docs.docker.io/en/latest/reference/api/docker_remote_api/). Since this plugin needs only a small subset of the whole API, it is OK to do the REST calls directly. That way the plugin has to deal only with Docker peculiarities and not docker-java's as well. As a side-effect, it has fewer transitive dependencies. FYI: There are other Docker Java/Groovy client libraries out, which might be suitable for plugins like this: [fabric/fabric-docker-api](https://github.com/fabric8io/fabric8/tree/master/fabric/fabric-docker-api), [spotify/docker-client](https://github.com/spotify/docker-client) or [gesellix-docker/docker-client](https://github.com/gesellix-docker/docker-client). Can you see the pattern ;-) ? So, final words: Enjoy this plugin, and please use the [issue tracker](https://github.com/fabric8io/docker-maven-plugin/issues) for anything that hurts, or when you have a wish list. ================================================ FILE: doc/migration-0.9.x.md ================================================ ## Migration Guide This recipes gives you some hint and help for migrating from the old (0.9.x) configuration syntax to the new one (0.10.x and later). If there are any issue when doing the migration or you do need some help, please raise an [issue](https://github.com/fabric8io/docker-maven-plugin/issues) with your original configuration and you will get some help for the migration. The biggest change was support for multiple images. The whole story about the change can be found in this [blog post](https://ro14nd.de/Docker-Maven-Plugin-Rewrite/). In the old version there was a single configurtion which resulted in one or two images, depending on the `mergeData` property. In general now all build aspects are collected now below a `` section and all runtime aspects in a `` section for each image. Typically it should be clear what configuration from the original, flat configuration list is a runtime or build aspect, here are some hints, depending on whether data merging is on or off (property `mergeData`) * `image` becomes the name of an image with a `` configuration (non-merging) or the base image within a `` element in the `` section (merging). * `dataImage` is used for the name of the data image (non-merging) with only a `` section or the name of the single image with both `` and `` section when merging is used. The [Examples](#examples) below show sample migrations for these two different situations and make this transformation clearer. ### Wait configuration When waiting for certain conditions during startup, in the old format there where dedicated configuration params for each possible conditions. Now they are collected within a subelement `` which is part of a `` configuration. For example: ```xml http://localhost:${port}/jolokia 10000 ``` becomes ``` http://localhost:${port}/jolokia ``` In addition the new syntax support also waiting on a log outpbut (``). ### Lifecycle binding The old version of the plugin combined some task: E.g. if you used `docker:start` or `docker:pull` a `docker:build` was done implicitely. In order to make stuff more explicite and easier to understand this is not the case anymore. So, when you bind to a lifecycle phase you have to add all steps explicitely: ```xml start pre-integration-test build start ... ``` ### Examples The migration is different depending on whether you use `mergeData` or not. ## Non merged images When `mergeData` was false, two images where created: One holding the data and one for the server which is connected to the data container during startup. So, the following old configuration ```xml false consol/tomcat-7.0 jolokia/data src/main/docker-assembly.xml -Xmx32m jolokia.port:8080 http://localhost:${jolokia.port}/jolokia 10000 ``` becomes in the new syntax a configuration for two images ```xml server consol/tomcat-7.0 data -Xmx32m jolokia.port:8080 http://localhost:${jolokia.port}/jolokia data jolokia/data src/main/docker-assembly.xml ``` Please note, that one image only has a `` configuration, the data image has a `` section only. They both are linked together during startup of the `server` container via `` (where the symbolic name of the data container can be used). ## Merged images When `mergeData` was true, only a single image was created. So the original configuration which looks like ```xml true consol/tomcat-7.0 jolokia/data src/main/docker-assembly.xml -Xmx32m jolokia.port:8080 http://localhost:${jolokia.port}/jolokia 10000 ``` can be directly translated to a single image configuration ```xml jolokia/data consol/tomcat-7.0 src/main/docker-assembly.xml -Xmx32m jolokia.port:8080 http://localhost:${jolokia.port}/jolokia ``` ### Misc renamings Some properties where renamed for consistencies sake: * `url` to `dockerHost` and the corresponding system property `docker.url` to `docker.host` * `color` to `useColor` ================================================ FILE: doc/readme-0.9.x.md ================================================ # docker-maven-plugin 0.9.x [![endorse](http://api.coderwall.com/fabric8io/endorsecount.png)](http://coderwall.com/fabric8io) [![Build Status](https://secure.travis-ci.org/fabric8io/docker-maven-plugin.png)](http://travis-ci.org/fabric8io/docker-maven-plugin) [![Flattr](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/73919/Jolokia-JMX-on-Capsaicin) This is a Maven plugin for managing Docker images and containers from within Maven builds. > **This document describes version 0.9.x of this plugin. Starting > with version 0.10.1 a new configuration syntax was introduced which > as documented in the [README](../README.md). See the > [CHANGELOG](changelog.md) for more details about the differences and > this [blog post](http://ro14nd.de/Docker-Maven-Plugin-Rewrite/) for > the motivation behind this restructuring. The 0.9.x version is > deprecated and won't be updated in the futuer. For a migration to > the new syntax please refer to this [guide](migration-0.9.x.md)** With this plugin it is possible to run completely isolated integration tests so you don't need to take care of shared resources. Ports can be mapped dynamically and made available as Maven properties. Build artifacts and dependencies can be accessed from within running containers, so that a file based deployment is easily possible and there is no need to use dedicated deployment support from plugins like [Cargo](https://codehaus-cargo.github.io/cargo/Maven2+plugin.html). This plugin's **highlights** are: * Configurable port mapping * Assigning dynamically selected host ports to Maven variables * Pulling of images (with progress indicator) if not yet downloaded * Optional waiting on a successful HTTP ping to the container * On-the-fly creation of Docker data images and containers with Maven artifacts and dependencies linked or merged into the containers under test. * Pushing data images to a registry * Setting of environment variables when creating the container * Support for SSL authentication (since Docker 1.3) * Color output ;-) This plugin is available from Maven central and can be connected to pre- and post-integration phase as seen below. Please refer also to the examples provided in the `samples/` directory. ````xml org.jolokia docker-maven-plugin 0.9.11 start pre-integration-test start stop post-integration-test stop ```` ## Maven Goals ### `docker:start` Creates and starts a specified docker container with the additional possibility to link artifacts and dependencies to this container, or, if `mergeData` is set to `true`, create a new image based on the given image and the assembly artifacts specified. #### Configuration | Parameter | Descriptions | Property | Default | | ------------ | ------------------------------------------------------- | -------------- | ----------------------- | | **url** | URL to the docker daemon | `docker.url` | `http://localhost:2375` | | **image** | Name of the docker image (e.g. `jolokia/tomcat:7.0.52`) | `docker.image` | none, required | | **ports** | List of ports to be mapped statically or dynamically. | | | | **env** | Additional environment variables used when creating a container | | | | **autoPull** | Set to `true` if an yet unloaded image should be automatically pulled | `docker.autoPull` | `true` | | **command** | Command to execute in the docker container |`docker.command`| | | **assemblyDescriptor** | Path to the data container assembly descriptor. See below for an explanation and example. | | | | **assemblyDescriptorRef** | Predefined assemblies which can be directly used. For possible values, see below. | | | | **mergeData** | If set to `true` create a new image based on the configured image and containing the assembly as described with `assemblyDescriptor` or `assemblyDescriptorRef` | `docker.mergeData` | `false` | | **dataBaseImage** | Base for the data image (used only when `mergeData` is false) | `docker.baseImage` | `busybox:latest` | | **dataImage** | Name to use for the created data image | `docker.dataImage` | `/:` | | **dataExportDir** | Name of the volume which gets exported | `docker.dataExportDir` | `/maven` | | **authConfig** | Authentication configuration when autopulling images. See below for details. | | | | **portPropertyFile** | Path to a file where dynamically mapped ports are written to | | | | **wait** | Ramp up time in milliseconds | `docker.wait` | | | **waitHttp** | Wait until this URL is reachable with an HTTP HEAD request. Dynamic port variables can be given, too | `docker.waitHttp` | | | **color** | Set to `true` for colored output | `docker.color` | `true` if TTY connected | | **skip** | If set to `true` skip the execution of this goal | `docker.skip` | | ### `docker:stop` Stops and removes a docker container. #### Configuration | Parameter | Descriptions | Property | Default | | ---------- | -------------------------------- | -------------- | ----------------------- | | **url** | URL to the docker daemon | `docker.url` | `http://localhost:4243` | | **image** | Which image to stop. All containers for this named image are stopped | `docker.image` | | | **keepContainer** | Set to `true` for not automatically removing the container after stopping it. | `docker.keepContainer` | | | **keepRunning** | Set to `true` for not stopping the container even when this goals runs. | `docker.keepRunning` | `false` | | **keepData** | Keep the data container and image after the build if set to `true` | `docker.keepData` | `false` | | **color** | Set to `true` for colored output | `docker.color` | `true` if TTY connected | | **skip** | If set to `true` skip the execution of this goal | `docker.skip` | | ### `docker:push` Push a data image to the registry. The data image is the same created during the `start` goal. See below for more information about how the data image is created. The registry to push is by default `registry.hub.docker.io` but can be specified as part of the `dataImage` name the Docker way. E.g. `docker.test.org:5000/data:1.5` will push the repository `data` with tag `1.5` to the registry `docker.test.org` at port `5000`. Security information (i.e. user and password) can be specified in multiple ways as described in an extra section. #### Configuration | Parameter | Descriptions | Property | Default | | ------------ | ------------------------------------------------------- | -------------- | ----------------------- | | **url** | URL to the docker daemon | `docker.url` | `http://localhost:2375` | | **image** | Name of the docker base image (e.g. `consol/tomcat:7.0.52`) | `docker.image` | none | | **autoPull** | Set to `true` if an yet unloaded image should be automatically pulled | `docker.autoPull` | `true` | | **assemblyDescriptor** | Path to the data container assembly descriptor. See below for an explanation and example | | | | **assemblyDescriptorRef** | Predefined assemblies which can be directly used. Possible values are given below | | | | **mergeData** | If set to `true` create a new image based on the configured image and containing the assembly as described with `assemblyDescriptor` or `assemblyDescriptorRef` | `docker.mergeData` | `false` | | **dataBaseImage** | Base for the data image (used only when `mergeData` is false) | `docker.baseImage` | `busybox:latest` | | **dataImage** | Name to use for the created data image | `docker.dataImage` | `/:` | | **dataExportDir** | Name of the volume which gets exported | `docker.dataExportDir` | `/maven` | | **keepData** | Keep the data image after the build if set to `true` | `docker.keepData` | `true` | | **authConfig** | Authentication configuration when pushing images. See below for details. | | | | **color** | Set to `true` for colored output | `docker.color` | `true` if TTY connected | | **skip** | If set to `true` skip the execution of this goal | `docker.skip` | | ### `docker:build` Build a data image without pushing. It works essentially the same as `docker:push` but does not push to a registry and does not delete the image afterwards. #### Configuration | Parameter | Descriptions | Property | Default | | ------------ | ------------------------------------------------------- | -------------- | ----------------------- | | **url** | URL to the docker daemon | `docker.url` | `http://localhost:2375` | | **image** | Name of the docker base image (e.g. `consol/tomcat:7.0.52`) | `docker.image` | none | | **autoPull** | Set to `true` if an yet unloaded base image should be automatically pulled | `docker.autoPull` | `true` | | **assemblyDescriptor** | Path to the data container assembly descriptor. See below for an explanation and example | | | | **assemblyDescriptorRef** | Predefined assemblies which can be directly used. Possible values are given below | | | | **mergeData** | If set to `true` create a new image based on the configured image and containing the assembly as described with `assemblyDescriptor` or `assemblyDescriptorRef` | `docker.mergeData` | `false` | | **dataBaseImage** | Base for the data image (used only when `mergeData` is false) | `docker.baseImage` | `busybox:latest` | | **dataImage** | Name to use for the created data image | `docker.dataImage` | `/:` | | **dataExportDir** | Name of the volume which gets exported | `docker.dataExportDir` | `/maven` | | **ports** | List of ports to be exposed | | | | **env** | List of environment variables to use for building | | | | **color** | Set to `true` for colored output | `docker.color` | `true` if TTY connected | | **skip** | If set to `true` skip the execution of this goal | `docker.skip` | | ## Dynamic Port mapping For the `start` goal, container port mapping may be configured using a `ports` declaration. ```xml 18080:8080 host.port:80 ``` A `port` stanza may take one of two forms: * A tuple consisting of two numeric values separated by a `:`. This form will result in an explicit mapping between the docker host and the corresponding port inside the container. In the above example, port 18080 would be exposed on the docker host and mapped to port 8080 in the running container. * A tuple consisting of a string and a numeric value separated by a `:`. In this form, the string portion of the tuple will correspond to a Maven property. If the property is undefined when the `start` task executes, a port will be dynamically selected by Docker in the range 49000 ... 49900 and assigned to the property which may then be used later in the same POM file. If the property exists and has a numeric value, that value will be used as the exposed port on the docker host as in the previous form. In the above example, the docker service will elect a new port and assign the value to the property `host.port` which may then later be used in a property expression similar to `${host.port}`. This can be used to pin a port from the outside when doing some initial testing similar to: mvn -Dhost.port=10080 docker:start Another useful configuration option is `portPropertyFile` with which a file can be specified to which the real port mapping is written after all dynamic ports has been resolved. The keys of this property file are the variable names, the values are the dynamically assigned host ports. This property file might be useful together with other Maven plugins which already resolved their Maven variables earlier in the lifecycle than this plugin so that the port variables might not be available to them. ## Setting environment variables When creating a container one or more environment variables can be set via configuration with the `env` parameter ```xml /opt/jdk8 -Djava.security.egd=file:/dev/./urandom ``` If you put this configuration into profiles you can easily create various test variants with a single image (e.g. by switching the JDK or whatever). ## Getting your assembly into the container With using the `assemblyDescriptor` or `assemblyDescriptorRef` option it is possible to bring local files, artifacts and dependencies into the running Docker container. This works as follows: * `assemblyDescriptor` points to a file describing the data to assemble. It has the same format as for creating assemblies with the [maven-assembly-plugin](http://maven.apache.org/plugins/maven-assembly-plugin/) , with some restrictions (see below). * Alternatively `assemblyDescriptorRef` can be used with the name of a predefined assembly descriptor. See below for possible values. * This plugin will create the assembly and create a Docker image on the fly which exports the assembly below a directory `/maven`. Typically this will be an extra image, but if the configuration parameter `mergeData` is set then the image which was configured for the `start` goal is used as a base image so that the data and e.g. application server are contained in the same image. This is useful for distributing a complete image where artifacts and the server are baked together. * From this image a (data) container is created and the 'real' container is started with a `volumesFrom` option pointing to this data container (if `mergeData` is not used). * That way, the container started has access to all the data created from the directory `/maven/` within the container. * The container command can check for the existence of this directory and deploy everything within this directory. Let's have a look at an example. In this case, we are deploying a war-dependency into a Tomcat container. The assembly descriptor `src/main/docker-assembly.xml` option may look like ````xml org.jolokia:jolokia-war . jolokia.war ```` Then you will end up with a data container which contains with a file `/maven/jolokia.war` which is mirrored into the main container. The plugin configuration could look like ````xml org.jolokia docker-maven-plugin .... jolokia/tomcat-7.0 src/main/docker-assembly.xml ... ```` The image `jolokia/tomcat-7.0` is a [trusted build](https://github.com/fabric8io/jolokia-it/tree/master/docker/tomcat/7.0) available from the central docker registry which uses a command `deploy-and-run.sh` that looks like this: ````bash #!/bin/sh DIR=${DEPLOY_DIR:-/maven} echo "Checking *.war in $DIR" if [ -d $DIR ]; then for i in $DIR/*.war; do file=$(basename $i) echo "Linking $i --> /opt/tomcat/webapps/$file" ln -s $i /opt/tomcat/webapps/$file done fi /opt/tomcat/bin/catalina.sh run ```` Before starting tomcat, this script will link every .war file it finds in `/maven` to `/opt/tomcat/webapps` which effectively will deploy them. Alternatively, the parameter `mergeData` could have been set to `true` in the plugin configuration. In this case no separate data image is created but an image which is based on the specified image (`jolokia/tomcat-7.0` in this example) and the assembly are directly available from `/maven`. This has the advantage that only a single image needs to be pushed containing both, the created artifact and application server. It is really that easy to deploy your artifacts. And it's fast (less than 10s for starting, deploying, testing (1 test) and stopping the container on my 4years old MBP using boot2docker). ### Assembly Descriptor The assembly descriptor has the same [format](http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html) as the the maven-assembly-plugin with the following exceptions: * `` are ignored, the assembly will always use a directory when preparing the data container (i.e. the format is fixed to `dir`) * The `` is ignored since only a single assembly descriptor is used (no need to distinguish multiple descriptors) This `docker-maven-plugin` comes with some predefined assembly descriptors which can be used with `assemblyDescritproRef`: * **artifact-with-dependencies** will copy your project's artifact and all its dependencies * **artifact** will copy only the project's artifact but no dependencies. * **project** will copy over the whole Maven project but with out `target/` directory. * **rootWar** will copy the artifact as `ROOT.war` to the exposed directory. I.e. Tomcat will then deploy the war under the root context. ## Cleanup Various configuration parameters of this plugin are available for cleaning up after a build: * `keepRunning` specifies that the container should not be stopped after the build. Obviously, the container and any data image created will be left alone as well. This option is especially useful when given as command line option `-Ddocker.keepRunning` for doing some debugging or developing integration tests. * `keepContainer` tells the plugin to not remove the container created from the image after the build (the container is stopped, though). If a merged container was created via the option `mergeData` then this container will remain as well as the on-the-fly created image this container belongs to. This is useful for post-mortem analysis of the container by e.g. looking at the logs. This option can be switched on with `-Ddocker.keepContainer`. If a separate data container is used, this data container and its image will stay as well. * `keepData` finally can be used to keep only the data container, but the other container should be be removed. This option has only an effect if `keepContainer` is `false`. That way, the created artifacts can be kept even after the build. ## Authentication When pulling (via the `autoPull` mode of `docker:start` and `docker:push`) or pushing image, it might be necessary to authenticate against a Docker registry. There are three different ways for providing credentials: * Using a `` section in the plugin configuration with `` and `` elements. * Providing system properties `docker.username` and `docker.password` from the outside * Using a `` configuration in the the `~/.m2/settings.xml` settings Using the username and password directly in the `pom.xml` is not recommended since this is widely visible. This is easiest and transparent way, though. Using an `` is straight forward: ````xml consol/tomcat-7.0 ... jolokia s!cr!t ```` The system property provided credentials are a good compromise when using CI servers like Jenkins. You simply provide the credentials from the outside: mvn -Ddocker.username=jolokia -Ddocker.password=s!cr!t docker:push The most secure and also the most *mavenish* way is to add a server to the Maven settings file `~/.m2/settings.xml`: ````xml registry.hub.docker.io jolokia s!cr!t .... ```` The server id must specify the registry to push to/pull from, which by default is central index `registry.hub.docker.io`. Here you should add you docker.io account for your repositories. ### Password encryption Regardless which mode you choose you can encrypt password as described in the [Maven documentation](http://maven.apache.org/guides/mini/guide-encryption.html). Assuming that you have setup a *master password* in `~/.m2/security-settings.xml` you can create easily encrypted passwords: ````bash $ mvn --encrypt-password Password: {QJ6wvuEfacMHklqsmrtrn1/ClOLqLm8hB7yUL23KOKo=} ```` This password then can be used in `authConfig`, `docker.password` and/or the `` setting configuration. However, putting an encrypted password into `authConfig` in the `pom.xml` doesn't make much sense, since this password is encrypted with an individual master password. ## SSL with keys and certificates The plugin can communicate with the Docker Host via SSL, too. This is the default now for Docker 1.3 (and Boot2Docker). SSL is switched on if the port used is `2376` which is the default, IANA registered SSL port of the Docker host (and plain HTTP for `2375`). The directory holding `ca.pem`, `key.pem` and `cert.pem` can be configured with the configuration parameter `certPath`. Alternatively, the environment variable `DOCKER_CERT_PATH` is evaluated and finally `~/.docker` is used as the last fallback. ## Examples This plugin comes with some commented examples in the `samples/` directory: * [data-jolokia-demo](https://github.com/fabric8io/docker-maven-plugin/tree/master/samples/data-jolokia-demo) is a setup for testing the [Jolokia](http://www.jolokia.org) HTTP-JMX bridge in a tomcat. It uses a Docker data container which is linked into the Tomcat container and contains the WAR files to deply * [cargo-jolokia-demo](https://github.com/fabric8io/docker-maven-plugin/tree/master/samples/cargo-jolokia-demo) is the same as above except that Jolokia gets deployed via [Cargo](https://codehaus-cargo.github.io/cargo/Maven2+plugin.html) For a complete example please refer to `samples/data-jolokia-demo/pom.xml`. In order to prove, that self contained builds are not a fiction, you might convince yourself by trying out this (on a UN*X like system): ````bash # Move away your local maven repository for a moment cd ~/.m2/ mv repository repository.bak # Fetch docker-maven-plugin cd /tmp/ git clone https://github.com/fabric8io/docker-maven-plugin.git cd docker-maven-plugin/ # Install plugin # (This is only needed until the plugin makes it to maven central) mvn install # Goto the sample cd samples/data-jolokia-demo # Run the integration test mvn verify # Use a 'merged' data image mvn -Pmerge-data verify # Push the data image mvn docker:push # Please note, that first it will take some time to fetch the image # from docker.io. The next time running it will be much faster. # Restore back you .m2 repo cd ~/.m2 mv repository /tmp/ mv repository.bak repository ```` ## Misc * [Script](https://gist.github.com/deinspanjer/9215467) for setting up NAT forwarding rules when using [boot2docker](https://github.com/boot2docker/boot2docker) on OS X * It is recommended to use the `maven-failsafe-plugin` for integration testing in order to stop the docker container even when the tests are failing. ## Why another docker-maven-plugin ? Spring feelings in 2014 seems to be quite fertile for the Java crowd's Docker awareness ;-). [Not only I](https://github.com/bibryam/docker-maven-plugin/issues/1) counted ~~5~~ 10 [maven-docker-plugins](https://github.com/search?q=docker-maven-plugin) on GitHub as of ~~April~~ July 2014, tendency increasing. It seems, that all of them have a slightly different focus, but all of them can do the most important tasks: Starting and stopping containers. So you might wonder, why I started this plugin if there were already quite some out here ? The reason is quite simple: I didn't knew them when I started and if you look at the commit history you will see that they all started their life roughly at the same time (March 2014). I expect there will be some settling soon and even some merging of efforts which I would highly appreciate and support. For what it's worth, here are some of my motivations for this plugin and what I want to achieve: * I needed a flexible, **dynamic port mapping** from container to host ports so that truly isolated build can be achieved. This should work on indirect setups with VMs like [boot2docker](https://github.com/boot2docker/boot2docker) for running on OS X. * It should be possible to **pull images** on the fly to get self-contained and repeatable builds with the only requirement to have docker installed. * The configuration of the plugin should be **simple** since usually developers don't want to dive into specific Docker details only to start a container. So, only a handful options should be exposed which needs not necessarily map directly to docker config setup. * The plugin should play nicely with [Cargo](https://codehaus-cargo.github.io/cargo/Maven2+plugin.html) so that deployments into containers can be easy. * I want as **less dependencies** as possible for this plugin. So I decided to *not* use the Java Docker API [docker-java](https://github.com/docker-java/docker-java) which is external to docker and has a different lifecycle than Docker's [remote API](http://docs.docker.io/en/latest/reference/api/docker_remote_api/). That is probably the biggest difference to the other docker-maven-plugins since AFAIK they all rely on this API. Since for this plugin I really need only a small subset of the whole API, I think it is ok to do the REST calls directly. That way I only have to deal with Docker peculiarities and not also with docker-java's one. As a side effect this plugin has less transitive dependencies. FYI: There is now yet another Docker Java client library out, which might be used for plugins like this, too: [fabric-docker-api](https://github.com/fabric8io/fabric8/tree/master/fabric/fabric-docker-api). (Just in case somebody wants to write yet another plugin ;-) In the meantime, enjoy this plugin, and please use the [issue tracker](https://github.com/fabric8io/docker-maven-plugin/issues) for anything what hurts. ================================================ FILE: doc/update_issue_links.sh ================================================ #!/bin/sh perl -i -p -e 's|\(\s*#(\d+)\s*\)|([#$1](https://github.com/fabric8io/docker-maven-plugin/issues/$1))|g' changelog.md ================================================ FILE: it/README.md ================================================ ## docker-maven-plugin examples This directory holds various examples for the usage of the docker-maven plugin. It can be used as starting point for your own projects. The examples are * **jolokia-integration-test** : The same integration test for [Jolokia](http://www.jolokia.org) in various way for defining it * **net** : Usage of various `net` modes (`bridge`, `none`, `host`, `container` and custom networks) ## Backlog * **base-layer** : Dependencies are put in a separate base layer * **multiple-docker-hosts** : Usage of multiple docker hosts ================================================ FILE: it/docker-compose/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dmp-sample-docker-compose 0.29-SNAPSHOT http://www.jolokia.org 7 tomcat org.jolokia jolokia-war 1.3.5 war io.fabric8 docker-maven-plugin build install build start install start stop install stop jolokia-war ${project.groupId}/${project.artifactId}:latest jolokia org.jolokia:jolokia-war . jolokia.war compose ================================================ FILE: it/docker-compose/src/main/docker/Dockerfile ================================================ FROM busybox:latest VOLUME ["/maven"] COPY j4p.war /maven/ ================================================ FILE: it/docker-compose/src/main/docker/docker-compose.yml ================================================ version: "2" services: jolokia-war: labels: "dmp.type": "example" "dmp.value": "100$$" tomcat: image: "fabric8/tomcat-7:latest" ports: - "8080:8080" environment: CATALINA_OPTS: "-Xmx32m" AB_OFF: "1" ulimits: memlock: hard: 2048 soft: 1024 volumes_from: - jolokia-war ================================================ FILE: it/dockerfile/README.md ================================================ ## d-m-p sample using a Dockerfile This example shows how to use docker-maven-plugin together with a Dockerfile. It is a simple `HelloWorld` servlet running on top of Jetty at the root context. The [Dockerfile](src/main/docker/Dockerfile) is located is `src/main/docker`. Please note how the assembly is added using the directory `maven` which will be created on the fly by this plugin when an `` is specified. To build and start a Jetty container with a mapped port at 8080 on the Docker host use ``` mvn package docker:build docker:run ``` ================================================ FILE: it/dockerfile/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dockerfile 0.29-SNAPSHOT war dmp-sample-dockerfile welcome.txt jetty ${project.artifactId} junit junit 3.8.1 test javax.servlet javax.servlet-api 3.1.0 commons-io commons-io 2.5 io.fabric8 docker-maven-plugin build install build start install start stop install stop fabric8:dmp-sample-dockerfile dockerfile ${project.basedir}/src/main/docker rootWar 8080:8080 ================================================ FILE: it/dockerfile/src/main/docker/Dockerfile ================================================ # Sample Dockerfile for use with the Docker file mode FROM ${base} ENV SAMPLE_BUILD_MODE=dockerfile LABEL PROJECT_NAME=hello-world \ PROJECT=${project.artifactId} # Arbitrary files can be added ADD ${file} / # In maven/ the files as specified in the section is stored # and need to be added manually COPY maven/ /var/lib/jetty/webapps/ EXPOSE 8080 ================================================ FILE: it/dockerfile/src/main/docker/welcome.txt ================================================ Hello World !!! ================================================ FILE: it/dockerfile/src/main/java/io/fabric8/dmp/samples/dockerfile/HelloWorldServlet.java ================================================ package io.fabric8.dmp.samples.dockerfile; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.FileUtils; /** * @author roland * @since 18.04.17 */ public class HelloWorldServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String txt = FileUtils.readFileToString(new File("/welcome.txt"), Charset.defaultCharset()); resp.getWriter().append(txt).flush(); resp.setHeader("Content-Type", "plain/text"); } } ================================================ FILE: it/dockerfile/src/main/webapp/WEB-INF/web.xml ================================================ HelloWold hello-world io.fabric8.dmp.samples.dockerfile.HelloWorldServlet hello-world / ================================================ FILE: it/dockerignore/.maven-dockerignore ================================================ target/** ================================================ FILE: it/dockerignore/Dockerfile ================================================ FROM busybox ================================================ FILE: it/dockerignore/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dmp-sample-dockerignore 0.29-SNAPSHOT docker-build io.fabric8 docker-maven-plugin true start install start stop install stop simple dmp-sample/dockerignore ${project.basedir} gzip ================================================ FILE: it/healthcheck/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dmp-sample-healthcheck 0.29-SNAPSHOT io.fabric8 docker-maven-plugin 500 default true always healthybox1 busybox1 busybox curl -f http://localhost/ || exit 1 sleep 2 true healthybox2 busybox2 busybox 5m 3s 3 curl -f http://localhost/ || exit 1 healthybox3 busybox3 busybox 5m 3 curl -f http://localhost/ || exit 1 true healthybox4 busybox4 busybox cmd 5m curl -f http://localhost/ || exit 1 healthybox5 busybox5 busybox 5m 3s 3 curl -f http://localhost/ || exit 1 unhealthybox6 busybox5 busybox none build pre-integration-test build ================================================ FILE: it/helloworld/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dmp-sample-helloworld 0.29-SNAPSHOT jar dmp-sample-helloworld junit junit 3.8.1 test org.apache.maven.plugins maven-compiler-plugin 3.6.1 1.8 1.8 org.codehaus.mojo exec-maven-plugin 1.5.0 io.fabric8.dmp.sample.helloworld.App org.apache.maven.plugins maven-jar-plugin 3.0.2 io.fabric8.dmp.sample.helloworld.App io.fabric8 docker-maven-plugin hello/sub/project/java:${project.version} hello-world openjdk:latest artifact java -jar maven/${project.name}-${project.version}.jar Hello World! docker:build install build docker:start install start docker:stop install stop ================================================ FILE: it/helloworld/src/main/java/io/fabric8/dmp/sample/helloworld/App.java ================================================ package io.fabric8.dmp.sample.helloworld; /** * Hello world! */ public class App { public static void main(String[] args) { System.out.println("Hello World!"); } } ================================================ FILE: it/helloworld/src/test/java/io/fabric8/dmp/sample/helloworld/AppTest.java ================================================ package io.fabric8.dmp.sample.helloworld; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Unit test for simple App. */ public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public AppTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( AppTest.class ); } /** * Rigourous Test :-) */ public void testApp() { assertTrue( true ); } } ================================================ FILE: it/log/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml io.fabric8 dmp-sample-log 0.29-SNAPSHOT io.fabric8 docker-maven-plugin build pre-integration-test build true always false jetty1 jetty .*Server:main: Started @\d+ms.* true jetty2 jetty .*Server:main: Started @\d+ms.* true ================================================ FILE: it/net/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dmp-sample-net 0.29-SNAPSHOT container true container:box2 bridge bridge bridge bridge host host host none none none custom test-network test-network io.fabric8 docker-maven-plugin 500 default true always box1 busybox alias ${box1.net} sh -c ip address | grep "inet "; echo "finish"; tail -f /dev/null 1 cyan finish box2 busybox ${box2.net} alias sh -c ip address | grep "inet "; echo "finish"; tail -f /dev/null 2 blue finish start pre-integration-test start stop post-integration-test stop ================================================ FILE: it/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT pom http://www.jolokia.org ${project.version} UTF-8 UTF-8 io.fabric8 docker-maven-plugin ${docker.maven.plugin.version} net volume properties dockerignore docker-compose smallest zero-config healthcheck helloworld dockerfile log run-java ================================================ FILE: it/properties/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dmp-sample-properties 0.29-SNAPSHOT docker-build io.fabric8 docker-maven-plugin start install start stop install stop true properties postgres.docker postgres:9.5.2 postgres ${itest.postgres.port}:5432 localhost superuser superuser-password 10000 PostgreSQL init process complete ================================================ FILE: it/run-java/Dockerfile ================================================ FROM openjdk:jre ADD target/${project.build.finalName}.jar /opt/hello-world.jar ADD target/docker-extra/run-java/run-java.sh /opt # See https://github.com/fabric8io-images/run-java-sh/ for more information # about run-java.sh CMD JAVA_MAIN_CLASS=HelloWorld sh /opt/run-java.sh ================================================ FILE: it/run-java/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml io.fabric8.dmp.samples dmp-sample-run-java jar 0.29-SNAPSHOT io.fabric8 docker-maven-plugin docker:build install build io.fabric8 run-java-sh 1.2.2 ================================================ FILE: it/run-java/src/main/java/HelloWorld.java ================================================ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world !"); } } ================================================ FILE: it/smallest/Dockerfile ================================================ FROM busybox CMD ["echo", "Hello", "world!"] ================================================ FILE: it/smallest/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml fabric8io dmp-sample-smallest 0.29-SNAPSHOT io.fabric8 docker-maven-plugin build pre-integration-test build ================================================ FILE: it/test.xml ================================================ build blas blub Test blub ================================================ FILE: it/volume/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml dmp-sample-volume 0.29-SNAPSHOT io.fabric8 docker-maven-plugin true always true newVolume start pre-integration-test volume-create start stop post-integration-test stop volume-remove ================================================ FILE: it/zero-config/Dockerfile ================================================ FROM openjdk:jre #RUN VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) ARG jar_file=target/zero-config-${project.version}.jar ADD $jar_file /tmp/zero-config.jar CMD java -cp /tmp/zero-config.jar HelloWorld ================================================ FILE: it/zero-config/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.29-SNAPSHOT ../pom.xml io.fabric8.dmp.samples zero-config jar 0.29-SNAPSHOT ${project.build.directory}/${project.build.finalName}.jar io.fabric8 docker-maven-plugin build pre-integration-test build ================================================ FILE: it/zero-config/src/main/java/HelloWorld.java ================================================ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world !"); } } ================================================ FILE: mvnw ================================================ #!/bin/sh # ---------------------------------------------------------------------------- # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- # Maven2 Start Up Batch script # # Required ENV vars: # ------------------ # JAVA_HOME - location of a JDK home dir # # Optional ENV vars # ----------------- # M2_HOME - location of maven2's installed home dir # MAVEN_OPTS - parameters passed to the Java VM when running Maven # e.g. to debug Maven itself, use # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 # MAVEN_SKIP_RC - flag to disable loading of mavenrc files # ---------------------------------------------------------------------------- if [ -z "$MAVEN_SKIP_RC" ] ; then if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi if [ -f "$HOME/.mavenrc" ] ; then . "$HOME/.mavenrc" fi fi # OS specific support. $var _must_ be set to either true or false. cygwin=false; darwin=false; mingw=false case "`uname`" in CYGWIN*) cygwin=true ;; MINGW*) mingw=true;; Darwin*) darwin=true # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home # See https://developer.apple.com/library/mac/qa/qa1170/_index.html if [ -z "$JAVA_HOME" ]; then if [ -x "/usr/libexec/java_home" ]; then export JAVA_HOME="`/usr/libexec/java_home`" else export JAVA_HOME="/Library/Java/Home" fi fi ;; esac if [ -z "$JAVA_HOME" ] ; then if [ -r /etc/gentoo-release ] ; then JAVA_HOME=`java-config --jre-home` fi fi if [ -z "$M2_HOME" ] ; then ## resolve links - $0 may be a link to maven's home PRG="$0" # need this for relative symlinks while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG="`dirname "$PRG"`/$link" fi done saveddir=`pwd` M2_HOME=`dirname "$PRG"`/.. # make it fully qualified M2_HOME=`cd "$M2_HOME" && pwd` cd "$saveddir" # echo Using m2 at $M2_HOME fi # For Cygwin, ensure paths are in UNIX format before anything is touched if $cygwin ; then [ -n "$M2_HOME" ] && M2_HOME=`cygpath --unix "$M2_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` fi # For Mingw, ensure paths are in UNIX format before anything is touched if $mingw ; then [ -n "$M2_HOME" ] && M2_HOME="`(cd "$M2_HOME"; pwd)`" [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" # TODO classpath? fi if [ -z "$JAVA_HOME" ]; then javaExecutable="`which javac`" if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. readLink=`which readlink` if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then if $darwin ; then javaHome="`dirname \"$javaExecutable\"`" javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" else javaExecutable="`readlink -f \"$javaExecutable\"`" fi javaHome="`dirname \"$javaExecutable\"`" javaHome=`expr "$javaHome" : '\(.*\)/bin'` JAVA_HOME="$javaHome" export JAVA_HOME fi fi fi if [ -z "$JAVACMD" ] ; then if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi else JAVACMD="`which java`" fi fi if [ ! -x "$JAVACMD" ] ; then echo "Error: JAVA_HOME is not defined correctly." >&2 echo " We cannot execute $JAVACMD" >&2 exit 1 fi if [ -z "$JAVA_HOME" ] ; then echo "Warning: JAVA_HOME environment variable is not set." fi CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { if [ -z "$1" ] then echo "Path not specified to find_maven_basedir" return 1 fi basedir="$1" wdir="$1" while [ "$wdir" != '/' ] ; do if [ -d "$wdir"/.mvn ] ; then basedir=$wdir break fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then wdir=`cd "$wdir/.."; pwd` fi # end of workaround done echo "${basedir}" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then echo "$(tr -s '\n' ' ' < "$1")" fi } BASE_DIR=`find_maven_basedir "$(pwd)"` if [ -z "$BASE_DIR" ]; then exit 1; fi export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} if [ "$MVNW_VERBOSE" = true ]; then echo $MAVEN_PROJECTBASEDIR fi MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then [ -n "$M2_HOME" ] && M2_HOME=`cygpath --path --windows "$M2_HOME"` [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"` [ -n "$MAVEN_PROJECTBASEDIR" ] && MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ $MAVEN_OPTS \ -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" ================================================ FILE: pom.xml ================================================ 4.0.0 3.0.3 io.fabric8 docker-maven-plugin 0.34-SNAPSHOT maven-plugin docker-maven-plugin Docker Maven Plugin http://github.com/fabric8io/docker-maven-plugin Roland Huss roland rhuss@redhat.com Developer Jae Gangemi jgangemi Developer UTF-8 3.3.9 1.43 3.0.0-M2 0.12.0 org.apache.maven maven-plugin-api provided ${maven.version} org.apache.maven maven-core ${maven.version} provided org.apache.maven maven-model ${maven.version} provided org.apache.maven maven-artifact ${maven.version} provided org.sonatype.plexus plexus-sec-dispatcher provided 1.3 org.codehaus.plexus plexus-utils provided 3.0.24 org.codehaus.plexus plexus-component-annotations provided 1.6 org.apache.maven.plugin-tools maven-plugin-annotations 3.5 provided org.apache.httpcomponents httpclient 4.5.5 com.github.jnr jnr-unixsocket 0.25 org.apache.commons commons-lang3 3.6 org.apache.commons commons-text 1.1 com.google.code.gson gson 2.8.5 org.fusesource.jansi jansi 1.16 org.bouncycastle bcpkix-jdk15on 1.65 org.apache.maven.plugins maven-assembly-plugin 3.1.0 org.apache.maven maven-project com.google.collections google-collections com.google.cloud.tools jib-core ${jib-core.version} org.yaml snakeyaml 1.26 com.google.guava guava 27.0.1-jre org.codehaus.plexus plexus-interpolation 1.24 org.hamcrest hamcrest-all 1.3 test org.jmockit jmockit ${jmockit.version} test junit junit 4.12 test org.skyscreamer jsonassert 1.5.0 test pl.pragmatists JUnitParams 1.1.0 test org.assertj assertj-core 2.6.0 test com.github.stefanbirkner system-rules 1.19.0 test maven-compiler-plugin 3.6.2 1.8 1.8 -Xlint:deprecation true org.apache.maven.plugins maven-plugin-plugin 3.5 docker true mojo-descriptor process-classes descriptor help-goal helpmojo maven-resources-plugin 3.0.2 copy-plexus-resources process-resources copy-resources ${basedir}/target/filtered-resources/META-INF/plexus src/main/resources/META-INF/plexus true copy-asciidoc process-resources copy-resources ${project.build.outputDirectory}/META-INF/doc/dmp src/main/asciidoc false org.codehaus.plexus plexus-component-metadata 1.7.1 ${basedir}/target/filtered-resources/META-INF/plexus generate-metadata org.apache.maven.plugins maven-release-plugin 2.5.3 maven-jar-plugin 3.0.2 true maven-deploy-plugin 2.8.2 org.apache.maven.plugins maven-source-plugin 3.0.0 org.apache.maven.plugins maven-javadoc-plugin 2.10.4 org.asciidoctor asciidoctor-maven-plugin 1.5.5 org.asciidoctor asciidoctorj 1.5.6 src/main/asciidoc font ${project.version} - org.apache.maven.plugins maven-surefire-plugin ${surefire.version} -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar org.apache.maven.wagon wagon-ssh-external 3.1.0 sonatype-nexus-snapshots Sonatype Nexus Snapshots https://oss.sonatype.org/content/repositories/snapshots/ sonatype-nexus-staging Nexus Release Repository https://oss.sonatype.org/service/local/staging/deploy/maven2/ GitHub https://github.com/fabric8io/docker-maven-plugin/issues/ scm:git:git://github.com/fabric8io/docker-maven-plugin.git scm:git:ssh://git@github.com/fabric8io/docker-maven-plugin.git HEAD git://github.com/fabric8io/docker-maven-plugin.git Apache 2 http://www.apache.org/licenses/LICENSE-2.0.txt repo A business-friendly OSS license release org.apache.maven.plugins maven-deploy-plugin true org.sonatype.plugins nexus-staging-maven-plugin 1.6.8 default-deploy deploy deploy https://oss.sonatype.org/ oss-sonatype-staging org.apache.maven.plugins maven-gpg-plugin 1.6 false sign-artifacts verify sign org.apache.maven.plugins maven-source-plugin false attach-sources jar org.apache.maven.plugins maven-javadoc-plugin false -Xdoclint:none attach-javadocs jar jacoco 0.7.9 org.jacoco org.jacoco.agent runtime ${jacoco.version} test org.jacoco jacoco-maven-plugin ${jacoco.version} instrument process-classes instrument restore test restore-instrumented-classes report org.apache.maven.plugins maven-surefire-plugin ${surefire.version} target/jacoco.exec doc-html org.asciidoctor asciidoctor-maven-plugin html coderay left generate-resources asciidoctor:process-asciidoc doc-pdf org.asciidoctor asciidoctor-maven-plugin pdf rouge org.asciidoctor asciidoctorj-pdf 1.5.0-alpha.16 generate-resources asciidoctor:process-asciidoc ================================================ FILE: release.groovy ================================================ #!/usr/bin/groovy def repo(){ return 'fabric8io/docker-maven-plugin' } def stage(){ return stageProject{ project = repo() useGitTagForNextVersion = true } } def approveRelease(project){ def releaseVersion = project[1] approve{ room = null version = releaseVersion console = null environment = 'fabric8' } } def release(project){ releaseProject{ stagedProject = project useGitTagForNextVersion = true helmPush = false groupId = 'io.fabric8' githubOrganisation = 'fabric8io' artifactIdToWatchInCentral = 'docker-maven-plugin' artifactExtensionToWatchInCentral = 'jar' } } def mergePullRequest(prId){ mergeAndWaitForPullRequest{ project = repo() pullRequestId = prId } } return this ================================================ FILE: release.sh ================================================ #!/bin/bash # ====================================== # Release script for docker-maven-plugin # ====================================== # Exit if any error occurs # Fail on a single failed command in a pipeline (if supported) set -o pipefail # Save global script args, use "build" as default if [ -z "$1" ]; then ARGS=("") else ARGS=("$@") fi # Fail on error and undefined vars (please don't use global vars, but evaluation of functions for return values) set -eu usage() { cat - < Version to release (e.g. "1.2.1"). One version arg is mandatory --snapshot-release Snapshot release which can be created on a daily basis. --settings Path to a custom settings.xml to use for the release. This file must contain all the credentials to be used for Sonatype. By default ~/.m2/settings.xml is used. --local-maven-repo Local dir for holding the local Maven repo cache. If not given, then a new temporary directory will be used (and removed after the release) --no-git-push Don't push the release tag (and symbolic major.minor tag) at the end --git-remote Name of the git remote to push to. If not given, its trying to be pushed to the git remote to which the currently checked out branch is attached to. Works only when on a branch, not when checked out directly. --log Write full log to , only print progress to screen EOT } # Dir where this script is located basedir() { # Default is current directory local script=${BASH_SOURCE[0]} # Resolve symbolic links if [ -L $script ]; then if readlink -f $script >/dev/null 2>&1; then script=$(readlink -f $script) elif readlink $script >/dev/null 2>&1; then script=$(readlink $script) elif realpath $script >/dev/null 2>&1; then script=$(realpath $script) else echo "ERROR: Cannot resolve symbolic link $script" exit 1 fi fi local dir=$(dirname "$script") local full_dir=$(cd "${dir}" && pwd) echo ${full_dir} } # Checks if a flag is present in the arguments. hasflag() { filters="$@" for var in "${ARGS[@]}"; do for filter in $filters; do if [ "$var" = "$filter" ]; then echo 'true' return fi done done } # Read the value of an option. readopt() { filters="$@" next=false for var in "${ARGS[@]}"; do if $next; then echo $var break; fi for filter in $filters; do if [[ "$var" = ${filter}* ]]; then local value="${var//${filter}=/}" if [ "$value" != "$var" ]; then echo $value return fi next=true fi done done } check_error() { local msg="$*" if [ "${msg//ERROR/}" != "${msg}" ]; then echo "===============================================================" echo $msg exit 1 fi } get_release_version() { if [ $(hasflag --snapshot-release) ]; then echo $(calc_timestamp_version) return fi local release_version=$(readopt --release-version) if [ -z "${release_version}" ]; then echo "ERROR: Please specify --release-version" return fi echo $release_version } calc_timestamp_version() { # ./mvnw -N help:evaluate -Dexpression="project.version" local pom_version=$(./mvnw -N help:evaluate -Dexpression="project.version" | grep '^[0-9]' | sed -e 's/\([0-9]*\.[0-9]*\).*/\1/') if [ -z "${pom_version}" ]; then echo "ERROR: Cannot extract version from pom.xml" exit 1 fi local patch_level=$(git tag | grep ^$pom_version | grep -v '-' | grep '[0-9]*\.[0-9]*\.' | sed -e s/${pom_version}.// | sort -n -r | head -1) echo "${pom_version}.$((patch_level+1))-$(date '+%Y%m%d')" } check_git_clean() { echo "==== Checking for clean Git Repo" set +e git diff-index --quiet HEAD -- local git_uncommitted=$? set -e if [ $git_uncommitted != 0 ]; then echo "Untracked or changed files exist. Please run release on a clean repo" git status exit 1 fi } update_pom_versions() { local version="$1" local maven_opts="$2" echo "==== Updating pom.xml versions to $version" ./mvnw ${maven_opts} versions:set -DnewVersion=$version -DprocessAllModules=true -DgenerateBackupPoms=false } extract_maven_opts() { local maven_opts="-Dmaven.repo.local=$1 --batch-mode" local settings_xml=$(readopt --settings-xml --settings) if [ -n "${settings_xml}" ]; then maven_opts="$maven_opts -s $settings_xml" fi echo $maven_opts } mvn_clean_install() { local maven_opts="$1" echo "==== Running 'mvn clean install'" ./mvnw ${maven_opts} clean install -DskipTests } build_and_stage_artefacts() { local maven_opts="$1" if [ $(hasflag --snapshot-release) ]; then echo "==== Building locally (--no-maven-release)" ./mvnw ${maven_opts} clean install -Pflash else echo "==== Building and staging Maven artefacts to Sonatype" ./mvnw ${maven_opts} -Prelease clean deploy -DstagingDescription="Staging Syndesis for $(readopt --release-version)" fi } drop_staging_repo() { local maven_opts="$1" if [ $(hasflag --snapshot-release) ]; then return fi echo "==== Dropping Sonatype staging repo" ./mvnw ${maven_opts} nexus-staging:drop -Prelease -DstagingDescription="Dropping repo" } release_staging_repo() { local maven_opts="$1" if [ $(hasflag --snapshot-release) ]; then return fi echo "==== Releasing Sonatype staging repo" ./mvnw ${maven_opts} -Prelease nexus-staging:release -DstagingDescription="Releasing $(readopt --release-version)" } git_commit_files() { local version=$1 echo "==== Committing files to local git" git_commit pom.xml "Update pom.xmls to $version" } git_tag_release() { local release_version=${1} echo "==== Tagging version $release_version" git tag -f "$release_version" } git_push() { local release_version=${1:-} if [ ! $(hasflag --no-git-push) ] && [ ! $(hasflag --dry-run -n) ]; then local remote=$(readopt --git-remote) if [ -z "${remote}" ]; then # Push to the remote attached to the local checkout branch remote=$(git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD) | sed -e 's/\([^\/]*\)\/.*/\1/') if [ -z "${remote}" ]; then echo "ERROR: Cannot find remote repository to git push to" exit 1 fi fi echo "==== Pushing to GitHub" if [ -n "$release_version" ]; then echo "* Pushing $release_version" if [ $(hasflag --snapshot-release) ]; then # Force push to allow multiple releases per day git push -f -u $remote $release_version else git push -u $remote $release_version fi fi fi } # =================================================================================== if [ $(hasflag --help -h) ]; then usage exit 0 fi cd $(basedir) release_version=$(get_release_version) check_error "$release_version" # Write to logfile if requested if [ $(readopt --log) ]; then logfile=$(readopt --log) touch $logfile tail -f $logfile > >(grep ^====) & tail_pid=$! trap "kill $tail_pid" EXIT exec >>$logfile 2>&1 sleep 1 fi # Verify that there are no modified file in git repo check_git_clean # Temporary local repository to guarantee a clean build local_maven_repo=$(readopt --local-maven-repo) if [ -z "$local_maven_repo" ]; then local_maven_repo=$(mktemp -d 2>/dev/null || mktemp -d -t 'maven_repo') trap "echo 'Removing temp maven repo $local_maven_repo' && rm -rf $local_maven_repo" "EXIT" fi # Calculate common maven options maven_opts="$(extract_maven_opts $local_maven_repo)" check_error $maven_opts # Set pom.xml version to the given release_version update_pom_versions "$release_version" "$maven_opts" # Make a clean install mvn_clean_install "$maven_opts" # Build and stage artefacts to Sonatype build_and_stage_artefacts "$maven_opts" # For a test run, we are done if [ $(hasflag --dry-run -n) ]; then drop_staging_repo "$maven_opts" echo "==== Dry run finished, nothing has been committed" echo "==== Use 'git reset --hard' to cleanup" exit 0 fi # ======================================================================== # Commit, tag, release, push # -------------------------- # Git Commit all changed files git_commit_files "$release_version" # Tag the release version git_tag_release "$release_version" # Push everything (if configured) git_push "$release_version" # Release staging repo release_staging_repo "$maven_opts" ================================================ FILE: samples/README.md ================================================ ## docker-maven-plugin examples This directory holds various examples for the usage of the docker-maven plugin. It can be used as starting point for your own projects. The examples are * **jolokia-integration-test** : The same integration test for [Jolokia](http://www.jolokia.org) in various way for defining it * **net** : Usage of various `net` modes (`bridge`, `none`, `host`, `container` and custom networks) ## Backlog * **base-layer** : Dependencies are put in a separate base layer * **multiple-docker-hosts** : Usage of multiple docker hosts ================================================ FILE: samples/cargo-jolokia/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml io.fabric8 dmp-sample-cargo-jolokia 0.34-SNAPSHOT http://www.jolokia.org 7.0 consol/tomcat-${tomcat} 1.2.1 UTF-8 UTF-8 org.jolokia jolokia-war ${jolokia.version} war junit junit 4.11 test com.jayway.restassured rest-assured 2.3.1 test io.fabric8 docker-maven-plugin true 10000 ${image} jolokia.port:8080 http://${docker.host.address}:${jolokia.port}/jolokia org.codehaus.cargo cargo-maven2-plugin tomcat7x remote runtime localhost ${jolokia.port} admin admin org.jolokia jolokia-war war /jolokia start-server pre-integration-test deploy maven-failsafe-plugin 2.17 ${jolokia.port} http://localhost:${jolokia.port}/jolokia ${jolokia.version} ================================================ FILE: samples/cargo-jolokia/src/test/java/io/fabric8/maven/docker/sample/jolokia/VersionIT.java ================================================ package io.fabric8.maven.docker.sample.jolokia; import com.jayway.restassured.RestAssured; import com.jayway.restassured.parsing.Parser; import com.jayway.restassured.path.json.JsonPath; import org.junit.Test; import static com.jayway.restassured.RestAssured.*; import static com.jayway.restassured.path.json.JsonPath.with; import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertEquals; /** * @author roland * @since 15.05.14 */ public class VersionIT { @Test public void testVersion() { String versionExpected = System.getProperty("jolokia.version"); String jolokiaUrl = System.getProperty("jolokia.url"); RestAssured.baseURI = jolokiaUrl; RestAssured.defaultParser = Parser.JSON; System.out.println("Checking URL: " + jolokiaUrl); // Need to do it that way since Jolokia doesnt return application/json as mimetype by default JsonPath json = with(get("/version").asString()); json.prettyPrint(); assertEquals(versionExpected, json.get("value.agent")); // Alternatively, set the mime type before, then Rest-assured's fluent API can be used given() .param("mimeType", "application/json") .get("/version") .then().assertThat() .header("content-type", containsString("application/json")) .body("value.agent", equalTo(versionExpected)) .body("timestamp", lessThanOrEqualTo((int) (System.currentTimeMillis() / 1000))) .body("status", equalTo(200)) .body("value.protocol", equalTo("7.1")) .body("value.config",notNullValue()); } } ================================================ FILE: samples/custom-net/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-custom-net 0.34-SNAPSHOT io.fabric8 docker-maven-plugin true 500 default true always true box1 busybox test-network box1 box1-alternative none sh -c tail -f /dev/null 1 cyan box2 busybox test-network box2 box1 none sh -c nslookup box1-alternative; tail -f /dev/null box1.test-network 2 blue start pre-integration-test start stop post-integration-test stop ================================================ FILE: samples/data-jolokia/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-data-jolokia 0.34-SNAPSHOT docker http://www.jolokia.org 8 tomcat docker.io/fabric8/${server.name}-${server.version}:latest 1.3.2 UTF-8 UTF-8 org.jolokia jolokia-war ${jolokia.version} war org.jolokia jolokia-it-war ${jolokia.version} war junit junit 4.11 com.jayway.restassured rest-assured 2.3.1 io.fabric8 docker-maven-plugin true 500 default true IfNotPresent org.apache.maven.plugins:maven-help-plugin:help server ${image} none data -Xmx32m 1 ${project.basedir}/src/main/docker/environment.properties ${jolokia.host}:${jolokia.port}:8080 Server startup http://${jolokia.host}:${jolokia.port}/jolokia GET 200 ls -l /maven 500 true red memlock 2048 1024 /var/lib/temp:size=10m none data fabric8/${project.artifactId}:latest ${project.version} app /maven dir www-data:www-data:www-data assembly.xml 5000 both maven-failsafe-plugin 2.17 ${jolokia.port} http://${docker.host.address}:${jolokia.port}/jolokia ${jolokia.version} org.apache.maven.plugins maven-compiler-plugin 3.2 1.7 1.7 org.apache.maven.plugins maven-help-plugin 2.2 snapshots-repo https://oss.sonatype.org/content/repositories/snapshots false true merge io.fabric8 docker-maven-plugin org.apache.maven.plugins:maven-help-plugin:help jolokia/${project.artifactId}:${project.version} jolokia ${image} ${project.version} ${project.artifactId} assembly.xml -Xmx32m 1 jolokia.port:8080 example http://${docker.host.address}:${jolokia.port}/jolokia true TC yellow copy ls -l /maven inline io.fabric8 docker-maven-plugin jolokia/${project.artifactId}:${project.version} jolokia ${image} dir jolokia-it org.jolokia:jolokia-war . jolokia.war org.jolokia:jolokia-it-war . jolokia-it.war jolokia.port:8080 http://${docker.host.address}:${jolokia.port}/jolokia dockerfile demo/Dockerfile io.fabric8 docker-maven-plugin true jolokia/${project.artifactId}-dockerfile:${project.version} jolokia ${dockerfile} maven jolokia.port:8080 http://${docker.host.address}:${jolokia.port}/jolokia props jolokia/${project.artifactId}:${project.version} service ${image} assembly.xml -Xmx32m 1 jolokia.port:8080 http://${docker.host.address}:${jolokia.port}/jolokia 10000 io.fabric8 docker-maven-plugin props docker wildfly io.fabric8 docker-maven-plugin jolokia/${project.artifactId}-wildfly:${project.version} jboss/wildfly:8.2.0.Final jboss:jboss:jboss /opt/jboss/wildfly/standalone/deployments assembly.xml jolokia.port:8080 http://${docker.host.address}:${jolokia.port}/jolokia tomcat tomcat 8 true jetty jetty 8 properties com.soebes.maven.plugins echo-maven-plugin 0.2 integration-test echo ============= Props ============= IP : ${docker.container.server.ip} machine io.fabric8 docker-maven-plugin maven true virtualbox ================================================ FILE: samples/data-jolokia/src/main/docker/assembly.xml ================================================ jolokia-it org.jolokia:jolokia-war . jolokia.war false org.jolokia:jolokia-it-war . jolokia-it.war false ${project.basedir}/src/main/docker test/ true hello.sh 755 ================================================ FILE: samples/data-jolokia/src/main/docker/demo/.maven-dockerignore ================================================ # Ignore patterns please-ignore/** ================================================ FILE: samples/data-jolokia/src/main/docker/demo/Dockerfile ================================================ FROM consol/tomcat-7.0:latest ARG deploymentDir ADD jolokia.war /${deploymentDir}/ ADD jolokia-it.war /${deploymentDir}/ ================================================ FILE: samples/data-jolokia/src/main/docker/demo/Dockerfile.test ================================================ FROM consol/tomcat-8.0:latest ARG deploymentDir ADD jolokia.war /maven/ ADD jolokia-it.war /maven/ ================================================ FILE: samples/data-jolokia/src/main/docker/demo/please-ignore/me.md ================================================ Yep, please ignore ! ================================================ FILE: samples/data-jolokia/src/main/docker/environment.properties ================================================ EXAMPLE_OF_AN_EXTERNAL_VARIABLE=Yes, it is ================================================ FILE: samples/data-jolokia/src/main/docker/hello.sh ================================================ #!/bin/sh echo "Hello world" ================================================ FILE: samples/data-jolokia/src/test/java/io/fabric8/maven/docker/sample/jolokia/VersionIT.java ================================================ package io.fabric8.maven.docker.sample.jolokia; import com.jayway.restassured.RestAssured; import com.jayway.restassured.parsing.Parser; import com.jayway.restassured.path.json.JsonPath; import org.junit.Test; import static com.jayway.restassured.RestAssured.*; import static com.jayway.restassured.path.json.JsonPath.with; import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertEquals; /** * @author roland * @since 15.05.14 */ public class VersionIT { @Test public void testVersion() { String versionExpected = System.getProperty("jolokia.version"); String jolokiaUrl = System.getProperty("jolokia.url"); RestAssured.baseURI = jolokiaUrl; RestAssured.defaultParser = Parser.JSON; System.out.println("Checking URL: " + jolokiaUrl); // Need to do it that way since Jolokia doesnt return application/json as mimetype by default JsonPath json = with(get("/version").asString()); json.prettyPrint(); assertEquals(versionExpected, json.get("value.agent")); // Alternatively, set the mime type before, then Rest-assured's fluent API can be used given() .param("mimeType", "application/json") .get("/version") .then().assertThat() .header("content-type", containsString("application/json")) .body("value.agent", equalTo(versionExpected)) .body("timestamp", lessThanOrEqualTo((int) (System.currentTimeMillis() / 1000))) .body("status", equalTo(200)) .body("value.protocol", equalTo("7.2")) .body("value.config",notNullValue()); } } ================================================ FILE: samples/docker-compose/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-docker-compose 0.34-SNAPSHOT http://www.jolokia.org 7 tomcat org.jolokia jolokia-war 1.3.5 war io.fabric8 docker-maven-plugin jolokia-war ${project.groupId}/${project.artifactId}:latest jolokia org.jolokia:jolokia-war . jolokia.war compose ================================================ FILE: samples/docker-compose/src/main/docker/Dockerfile ================================================ FROM busybox:latest VOLUME ["/maven"] COPY j4p.war /maven/ ================================================ FILE: samples/docker-compose/src/main/docker/docker-compose.yml ================================================ version: "2" services: jolokia-war: labels: "dmp.type": "example" "dmp.value": "100$$" tomcat: image: "fabric8/tomcat-7:latest" ports: - "8080:8080" environment: CATALINA_OPTS: "-Xmx32m" AB_OFF: "1" ulimits: memlock: hard: 2048 soft: 1024 volumes_from: - jolokia-war ================================================ FILE: samples/dockerfile/README.md ================================================ ## d-m-p sample using a Dockerfile This example shows how to use docker-maven-plugin together with a Dockerfile. It is a simple `HelloWorld` servlet running on top of Jetty at the root context. The [Dockerfile](src/main/docker/Dockerfile) is located is `src/main/docker`. Please note how the assembly is added using the directory `maven` which will be created on the fly by this plugin when an `` is specified. To build and start a Jetty container with a mapped port at 8080 on the Docker host use ``` mvn package docker:build docker:run ``` ================================================ FILE: samples/dockerfile/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dockerfile 0.34-SNAPSHOT war dmp-sample-dockerfile welcome.txt jetty ${project.artifactId} junit junit 3.8.1 test javax.servlet javax.servlet-api 3.1.0 commons-io commons-io 2.5 io.fabric8 docker-maven-plugin fabric8:dmp-sample-dockerfile dockerfile ${project.basedir}/src/main/docker rootWar 8080:8080 ================================================ FILE: samples/dockerfile/src/main/docker/Dockerfile ================================================ # Sample Dockerfile for use with the Docker file mode FROM ${base} ENV SAMPLE_BUILD_MODE=dockerfile LABEL PROJECT_NAME=hello-world \ PROJECT=${project.artifactId} # Arbitrary files can be added ADD ${file} / # In maven/ the files as specified in the section is stored # and need to be added manually COPY maven/ /var/lib/jetty/webapps/ EXPOSE 8080 ================================================ FILE: samples/dockerfile/src/main/docker/welcome.txt ================================================ Hello World !!! ================================================ FILE: samples/dockerfile/src/main/java/io/fabric8/dmp/samples/dockerfile/HelloWorldServlet.java ================================================ package io.fabric8.dmp.samples.dockerfile; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.FileUtils; /** * @author roland * @since 18.04.17 */ public class HelloWorldServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String txt = FileUtils.readFileToString(new File("/welcome.txt"), Charset.defaultCharset()); resp.getWriter().append(txt).flush(); resp.setHeader("Content-Type", "plain/text"); } } ================================================ FILE: samples/dockerfile/src/main/webapp/WEB-INF/web.xml ================================================ HelloWold hello-world io.fabric8.dmp.samples.dockerfile.HelloWorldServlet hello-world / ================================================ FILE: samples/dockerignore/.maven-dockerignore ================================================ target/** ================================================ FILE: samples/dockerignore/Dockerfile ================================================ FROM busybox ================================================ FILE: samples/dockerignore/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-dockerignore 0.34-SNAPSHOT docker-build io.fabric8 docker-maven-plugin true simple dmp-sample/dockerignore ${project.basedir} gzip ================================================ FILE: samples/healthcheck/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-healthcheck 0.34-SNAPSHOT io.fabric8 docker-maven-plugin 500 default true always healthybox1 busybox1 busybox curl -f http://localhost/ || exit 1 sleep 2 true healthybox2 busybox2 busybox 5m 3s 3 curl -f http://localhost/ || exit 1 healthybox3 busybox3 busybox 5m 3 curl -f http://localhost/ || exit 1 true healthybox4 busybox4 busybox cmd 5m curl -f http://localhost/ || exit 1 healthybox5 busybox5 busybox 5m 3s 30m 3 curl -f http://localhost/ || exit 1 unhealthybox6 busybox5 busybox none start pre-integration-test start stop post-integration-test stop ================================================ FILE: samples/helloworld/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-helloworld 0.34-SNAPSHOT jar dmp-sample-helloworld junit junit 3.8.1 test org.apache.maven.plugins maven-compiler-plugin 3.6.1 1.8 1.8 org.codehaus.mojo exec-maven-plugin 1.5.0 io.fabric8.dmp.sample.helloworld.App org.apache.maven.plugins maven-jar-plugin 3.0.2 io.fabric8.dmp.sample.helloworld.App io.fabric8 docker-maven-plugin hello/sub/project/java:${project.version} hello-world openjdk:latest artifact java -jar maven/${project.name}-${project.version}.jar Hello World! docker:start install run ================================================ FILE: samples/helloworld/src/main/java/io/fabric8/dmp/sample/helloworld/App.java ================================================ package io.fabric8.dmp.sample.helloworld; /** * Hello world! */ public class App { public static void main(String[] args) { System.out.println("Hello World!"); } } ================================================ FILE: samples/helloworld/src/test/java/io/fabric8/dmp/sample/helloworld/AppTest.java ================================================ package io.fabric8.dmp.sample.helloworld; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Unit test for simple App. */ public class AppTest extends TestCase { /** * Create the test case * * @param testName name of the test case */ public AppTest( String testName ) { super( testName ); } /** * @return the suite of tests being tested */ public static Test suite() { return new TestSuite( AppTest.class ); } /** * Rigourous Test :-) */ public void testApp() { assertTrue( true ); } } ================================================ FILE: samples/log/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml io.fabric8 dmp-sample-log 0.34-SNAPSHOT io.fabric8 docker-maven-plugin true always false jetty1 jetty .*Server:main: Started @\d+ms.* true jetty2 jetty .*Server:main: Started @\d+ms.* true ================================================ FILE: samples/multi-wait/pom.xml ================================================ 4.0.0 io.fabric8 dmp-sample-multi-wait 0.34-SNAPSHOT io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml io.fabric8 docker-maven-plugin none db postgres:9.6.0 password database system is ready to accept connections db2 postgres:9.6.0 password database system is ready to accept connections web jboss/wildfly:9.0.2.Final db,db2 web.port:8080 WildFly Full .* \(WildFly Core .*\) started start pre-integration-test start stop post-integration-test stop org.apache.maven.plugins maven-failsafe-plugin integration-test verify ================================================ FILE: samples/net/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-net 0.34-SNAPSHOT container true container:box2 bridge bridge bridge bridge host host host none none none custom test-network test-network io.fabric8 docker-maven-plugin 500 default true always box1 busybox alias ${box1.net} sh -c ip address | grep "inet "; echo "finish"; tail -f /dev/null 1 cyan finish box2 busybox ${box2.net} alias sh -c ip address | grep "inet "; echo "finish"; tail -f /dev/null 2 blue finish start pre-integration-test start stop post-integration-test stop ================================================ FILE: samples/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT pom http://www.jolokia.org ${project.version} UTF-8 UTF-8 io.fabric8 docker-maven-plugin ${docker.maven.plugin.version} net custom-net volume properties dockerignore docker-compose data-jolokia smallest zero-config healthcheck multi-wait helloworld dockerfile cargo-jolokia log run-java spring-boot-with-jib ================================================ FILE: samples/properties/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-properties 0.34-SNAPSHOT docker-build io.fabric8 docker-maven-plugin true properties postgres.docker postgres:9.5.2 postgres ${itest.postgres.port}:5432 localhost superuser superuser-password 10000 PostgreSQL init process complete ================================================ FILE: samples/run-java/Dockerfile ================================================ FROM openjdk:jre ADD target/${project.build.finalName}.jar /opt/hello-world.jar ADD target/docker-extra/run-java/run-java.sh /opt # See https://github.com/fabric8io-images/run-java-sh/ for more information # about run-java.sh CMD JAVA_MAIN_CLASS=HelloWorld sh /opt/run-java.sh ================================================ FILE: samples/run-java/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml io.fabric8.dmp.samples dmp-sample-run-java jar 0.34-SNAPSHOT io.fabric8 docker-maven-plugin io.fabric8 run-java-sh 1.2.2 ================================================ FILE: samples/run-java/src/main/java/HelloWorld.java ================================================ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world !"); } } ================================================ FILE: samples/smallest/Dockerfile ================================================ FROM busybox CMD ["echo", "Hello", "world!"] ================================================ FILE: samples/smallest/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml fabric8io dmp-sample-smallest 0.34-SNAPSHOT io.fabric8 docker-maven-plugin ================================================ FILE: samples/spring-boot-with-jib/README.md ================================================ # Spring Boot Sample with JIB Build Mode This is also a Spring Boot application to demonstrate how Docker Maven Plugin handles build workflows by integrating with [JIB](https://github.com/GoogleContainerTools/jib) which makes Docker Maven Plugin independent of docker daemon. ### How to Build? You can compile project as usual by issuing a simple `mvn clean install` command. ## Standard Configuration You can build images in JIB mode by just setting `docker.build.jib=true`. Plugin would switch to JIB Build and build your image tarball into project's output directory. You can either copy this tarball and load into some docker daemon or push your image to some registry. I will be proceeding with building image and pushing to docker hub. So I would modify `pom.xml` properties to set `docker.user` to my dockerhub username: ```.xml exampleuser ``` ### Standard Configuration Build: You can see that my local docker daemon is not running: ```.shell script # Check Docker Daemon Status spring-boot-with-jib : $ systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: inactive (dead) since Sat 2020-08-29 16:55:32 IST; 3min 2s ago TriggeredBy: ● docker.socket Docs: https://docs.docker.com Main PID: 4631 (code=exited, status=0/SUCCESS) Aug 29 16:49:28 localhost.localdomain dockerd[4639]: time="2020-08-29T16:49:28.401304638+05:30" level=info msg="shim reaped" id=3c5e5b5555fdd8a020bf248d1a7e09d1578de62c0130> Aug 29 16:49:28 localhost.localdomain dockerd[4631]: time="2020-08-29T16:49:28.410926927+05:30" level=info msg="ignoring event" module=libcontainerd namespace=moby topic=/t> Aug 29 16:55:31 localhost.localdomain systemd[1]: Stopping Docker Application Container Engine... Aug 29 16:55:31 localhost.localdomain dockerd[4631]: time="2020-08-29T16:55:31.170170702+05:30" level=info msg="Processing signal 'terminated'" Aug 29 16:55:31 localhost.localdomain dockerd[4631]: time="2020-08-29T16:55:31.174848312+05:30" level=info msg="Daemon shutdown complete" Aug 29 16:55:31 localhost.localdomain dockerd[4631]: time="2020-08-29T16:55:31.174895349+05:30" level=info msg="stopping event stream following graceful shutdown" error="co> Aug 29 16:55:31 localhost.localdomain dockerd[4631]: time="2020-08-29T16:55:31.175137692+05:30" level=info msg="stopping healthcheck following graceful shutdown" module=lib> Aug 29 16:55:31 localhost.localdomain dockerd[4631]: time="2020-08-29T16:55:31.175219226+05:30" level=info msg="stopping event stream following graceful shutdown" error="co> Aug 29 16:55:32 localhost.localdomain systemd[1]: docker.service: Succeeded. Aug 29 16:55:32 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine. spring-boot-with-jib : $ ``` To build project issue this command: > mvn docker:build ```.text [INFO] Scanning for projects... [INFO] [INFO] ---------< io.fabric8.dmp.samples:dmp-sample-spring-boot-jib >---------- [INFO] Building Docker Maven Plugin :: Spring Boot JIB 0.33-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- docker-maven-plugin:0.33-SNAPSHOT:build (default-cli) @ dmp-sample-spring-boot-jib --- [INFO] DOCKER> Building Container image with JIB(Java Image Builder) mode [INFO] DOCKER> JIB image build started [INFO] DOCKER> Preparing assembly files [INFO] Copying files to /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-dmp-sample-jib/build/maven [INFO] Building tar: /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-dmp-sample-jib/tmp/docker-build.tar [WARNING] Cannot include project artifact: io.fabric8.dmp.samples:dmp-sample-spring-boot-jib:jar:0.33-SNAPSHOT; it doesn't have an associated file or directory. [WARNING] The following patterns were never triggered in this artifact inclusion filter: o 'io.fabric8.dmp.samples:dmp-sample-spring-boot-jib' JIB> Base image 'fabric8/java-centos-openjdk8-jdk:1.5.6' does not use a specific image digest - build may not be reproducible JIB> Containerizing application with the following files: JIB> : JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-dmp-sample-jib/build/maven JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-dmp-sample-jib/build/maven/dmp-sample-spring-boot-jib-0.33-SNAPSHOT.jar JIB> : JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-dmp-sample-jib/build/Dockerfile JIB> Getting manifest for base image fabric8/java-centos-openjdk8-jdk:1.5.6... JIB> Building layer... JIB> Building layer... JIB> The base image requires auth. Trying again for fabric8/java-centos-openjdk8-jdk:1.5.6... JIB> Retrieving registry credentials for registry-1.docker.io... JIB> Using base image with digest: sha256:92530aa1eb4c49e3b1d033f94e9cd4dc891d49922459e13f84e59c9d68d800eb JIB> Container program arguments set to [java, -jar, /maven/dmp-sample-spring-boot-jib-0.33-SNAPSHOT.jar] JIB> Building image to tar file... JIB> [======================== ] 80.0% complete > writing to tar file JIB> [==============================] 100.0% complete [INFO] DOCKER> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-dmp-sample-jib/tmp/docker-build.tar successfully built [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 13.587 s [INFO] Finished at: 2020-08-29T17:08:10+05:30 [INFO] ------------------------------------------------------------------------ ``` JIB build creates a tarball as image output(You can see in logs that it shows the build image tarball). You can then load this image into some other docker daemon like this: ``` spring-boot-with-jib : $ docker load -i /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-dmp-sample-jib/tmp/docker-build.tar f38418c08d5d: Loading layer [==================================================>] 17.85MB/17.85MB f1ef686aa9e0: Loading layer [==================================================>] 215B/215B Loaded image: rohankanojia/spring-boot-dmp-sample-jib:latest ``` **Note**: Make sure that `docker.build.jib` is disabled when you're using other plugin goals. Jib mode does not work with other goals. After this, you can use [`docker:start`](http://dmp.fabric8.io/#docker:start) as usual Or you may want to push image to some registry as described in next section. ### Zero Configuration Push In order to push image, you need to make sure that your image name is set with respect to your registry. I'm going to push the image to docker hub so `${docker.user}/spring-boot-dmp-sample-jib` would be my image name. You can push image with [`docker:push`](http://dmp.fabric8.io/#docker:push) goal as usual, I already have `docker.build.jib=true` set in project properties: ``` spring-boot-with-jib : $ mvn docker:push [INFO] Scanning for projects... [INFO] [INFO] ---------< io.fabric8.dmp.samples:dmp-sample-spring-boot-jib >---------- [INFO] Building Docker Maven Plugin :: Spring Boot JIB 0.33-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- docker-maven-plugin:0.33-SNAPSHOT:push (default-cli) @ dmp-sample-spring-boot-jib --- [INFO] DOCKER> Pushing Container image with JIB(Java Image Builder) mode [INFO] DOCKER> This push refers to: rohankanojia/spring-boot-dmp-sample-jib JIB> Containerizing application with the following files: JIB> Retrieving registry credentials for registry-1.docker.io... JIB> Container program arguments set to [java, -jar, /maven/dmp-sample-spring-boot-jib-0.33-SNAPSHOT.jar] (inherited from base image) JIB> Pushing manifest for latest... JIB> [==============================] 100.0% complete [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:57 min [INFO] Finished at: 2020-08-29T17:36:11+05:30 [INFO] ------------------------------------------------------------------------ spring-boot-with-jib : $ ``` ## JIB with Customized Assembly This profile tries to add some extra files inside the image. If you see there is an extra directory `static` in project base directory. It is the copied to target image. ### JIB with Customized Assembly Build Now to build you need to issue same build goal but with different profile, build goal generates a tarball which needs to be loaded into your docker daemon afterwards. Or maybe you can push it to some registry: > mvn docker:build -PJib-With-Assembly ``` spring-boot-with-jib : $ mvn docker:build -PJib-With-Assembly [INFO] Scanning for projects... [INFO] [INFO] ---------< io.fabric8.dmp.samples:dmp-sample-spring-boot-jib >---------- [INFO] Building Docker Maven Plugin :: Spring Boot JIB 0.33-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- docker-maven-plugin:0.33-SNAPSHOT:build (default-cli) @ dmp-sample-spring-boot-jib --- [INFO] DOCKER> Building Container image with JIB(Java Image Builder) mode [INFO] DOCKER> JIB image build started [INFO] DOCKER> Preparing assembly files [INFO] Copying files to /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-sample/build/my-project-assembly JIB> Base image 'fabric8/java-centos-openjdk8-jdk:1.5.6' does not use a specific image digest - build may not be reproducible JIB> Containerizing application with the following files: JIB> : JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-sample/build/my-project-assembly JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-sample/build/my-project-assembly/static JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-sample/build/my-project-assembly/static/testFile.txt JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-sample/build/my-project-assembly/dmp-sample-spring-boot-jib-0.33-SNAPSHOT.jar JIB> : JIB> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-sample/build/Dockerfile JIB> Getting manifest for base image fabric8/java-centos-openjdk8-jdk:1.5.6... JIB> Building layer... JIB> Building layer... JIB> The base image requires auth. Trying again for fabric8/java-centos-openjdk8-jdk:1.5.6... JIB> Retrieving registry credentials for registry-1.docker.io... JIB> Using base image with digest: sha256:92530aa1eb4c49e3b1d033f94e9cd4dc891d49922459e13f84e59c9d68d800eb JIB> Container program arguments set to [java, -jar, /my-project-assembly/dmp-sample-spring-boot-jib-0.33-SNAPSHOT.jar] JIB> Building image to tar file... JIB> [======================== ] 80.0% complete > writing to tar file JIB> [==============================] 100.0% complete [INFO] DOCKER> /home/rohaan/work/repos/docker-maven-plugin/samples/spring-boot-with-jib/target/docker/rohankanojia/spring-boot-sample/tmp/docker-build.tar successfully built [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 13.173 s [INFO] Finished at: 2020-08-29T17:40:13+05:30 [INFO] ------------------------------------------------------------------------ ``` ### Jib With Customized Assembly Push Pushing image to docker hub in this case, you can provide registry credentials in plugin XML config, in `~/.m2/settings.xml` or in `~/.docker/config.json`: > mvn docker:push -PJib-With-Assembly ``` spring-boot-with-jib : $ mvn docker:push -PJib-With-Assembly [INFO] Scanning for projects... [INFO] [INFO] ---------< io.fabric8.dmp.samples:dmp-sample-spring-boot-jib >---------- [INFO] Building Docker Maven Plugin :: Spring Boot JIB 0.33-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- docker-maven-plugin:0.33-SNAPSHOT:push (default-cli) @ dmp-sample-spring-boot-jib --- [INFO] DOCKER> Pushing Container image with JIB(Java Image Builder) mode [INFO] DOCKER> This push refers to: rohankanojia/spring-boot-sample JIB> Containerizing application with the following files: JIB> Retrieving registry credentials for registry-1.docker.io... JIB> Container program arguments set to [java, -jar, /my-project-assembly/dmp-sample-spring-boot-jib-0.33-SNAPSHOT.jar] (inherited from base image) JIB> [==================== ] 66.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> Skipping push; BLOB already exists on target registry : digest: sha256:707713df6baa24192428099d6444fed7fe3c91dc10bad2742b7350f0147b1b3b, size: 8851 JIB> [==================== ] 67.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> Skipping push; BLOB already exists on target registry : digest: sha256:109b828942fdee847c02ec43b13105bf0d1bc1701675a4306781193f11c997df, size: 6543 JIB> [===================== ] 68.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> Skipping push; BLOB already exists on target registry : digest: sha256:a44f5f69f08a44895565ad9cdfa05f3378a46205cf81c64de068efed4f644a46, size: 467 JIB> Skipping push; BLOB already exists on target registry : digest: sha256:8e2fef958d6c5532e73960cab9b4acf1de2fa0dac8ce1d404751de240157e5cd, size: 739790 JIB> [===================== ] 70.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> Skipping push; BLOB already exists on target registry : digest: sha256:743ce65d298dc1684e06ba2d255db095cceaf75060dcbdff43baa8a7e525255a, size: 100 JIB> [===================== ] 69.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> Skipping push; BLOB already exists on target registry : digest: sha256:ac9208207adaac3a48e54a4dc6b49c69e78c3072d2b3add7efdabf814db2133b, size: 75161332 JIB> [====================== ] 72.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> [====================== ] 71.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> Skipping push; BLOB already exists on target registry : digest: sha256:6b82b8ee52d8ef43d1b35637e65d9134277e63fd23316516c084ab0dad7a017b, size: 1375 JIB> [====================== ] 73.7% complete > pushing blob sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6JIB> Skipping push; BLOB already exists on target registry : digest: sha256:0a2b4dc56d7e822495adcdfa8a2c2316e9ae420d84a6a5e8e9d0b505a5fddcd1, size: 6539 JIB> [====================== ] 74.7% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> Skipping push; BLOB already exists on target registry : digest: sha256:08f3d26bbf994fd2c8ce6418a0b090bee22878c7998f0e78b7247a860411bbb2, size: 86409418 JIB> [======================= ] 75.8% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> Skipping push; BLOB already exists on target registry : digest: sha256:99230c1ff85faaf8fd0c9ba8db6b20d009db4fb35f17f7b6a24a6baa6821c306, size: 4702 JIB> [========================== ] 86.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> Skipping push; BLOB already exists on target registry : digest: sha256:18e8deddb3f584f36c47b481067a6fa0a3a977b71df199a8d89ee8720b9c587c, size: 239 JIB> [========================== ] 87.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 87.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 87.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 87.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 87.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 87.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 87.9% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.0% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.0% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.0% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.1% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.1% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.2% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.3% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [========================== ] 88.3% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [=========================== ] 88.4% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [=========================== ] 88.5% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [=========================== ] 88.6% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [=========================== ] 88.7% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [=========================== ] 88.8% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> [=========================== ] 88.8% complete > pushing blob sha256:46839fd680b76fed7005bc63ae1207193c129051c10dJIB> Pushing manifest for latest... JIB> [==============================] 100.0% complete [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 29.416 s [INFO] Finished at: 2020-08-29T17:43:57+05:30 [INFO] ------------------------------------------------------------------------ ``` You can check afterwards whether the loaded container contains the file you mentioned in assembly or not: ``` spring-boot-with-jib : $ docker container run -it rohankanojia/spring-boot-sample:latest /bin/bash [root@c402fe994291 /]# ls Dockerfile bin dev home lib64 mnt opt root sbin sys usr anaconda-post.log deployments etc lib media my-project-assembly proc run srv tmp var [root@c402fe994291 /]# ls my-project-assembly/ dmp-sample-spring-boot-jib-0.33-SNAPSHOT.jar static [root@c402fe994291 /]# ls my-project-assembly/static/ testFile.txt [root@c402fe994291 /]# cat my-project-assembly/static/testFile.txt I should be present [root@c402fe994291 /]# exit exit ``` ### Registry Configuration You can provide registry credentials in 3 formats: - You can do a `docker login`(for Docker Hub) or `docker login docker.io testuser testpassword quay.io testuser testpassword ``` - You can provide registry credentials as part of XML configuration: ``` org.eclipse.jkube kubernetes-maven-plugin ${project.version} testuser testpassword ``` ================================================ FILE: samples/spring-boot-with-jib/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-spring-boot-jib 0.33-SNAPSHOT jar Docker Maven Plugin Example with Spring Boot With Build Mode JIB sonatype-nexus-snapshots Sonatype Nexus Snapshots https://oss.sonatype.org/content/repositories/snapshots/ sonatype-nexus-staging Nexus Release Repository https://oss.sonatype.org/service/local/staging/deploy/maven2/ 1.8 1.8 true fabric8 2.3.3.RELEASE org.springframework.boot spring-boot-starter-web ${spring.version} org.springframework.boot spring-boot-starter-actuator ${spring.version} jakarta.xml.bind jakarta.xml.bind-api 2.3.2 org.glassfish.jaxb jaxb-runtime 2.3.2 org.springframework.boot spring-boot-maven-plugin ${spring.version} repackage io.fabric8 docker-maven-plugin 0.33-SNAPSHOT ${docker.user}/spring-boot-dmp-sample-jib fabric8/java-centos-openjdk8-jdk:1.5.6 artifact java -jar /maven/${project.artifactId}-${project.version}.jar 8080 Jib-With-Assembly io.fabric8 docker-maven-plugin 0.33-SNAPSHOT ${docker.user}/spring-boot-dmp-sample-jib fabric8/java-centos-openjdk8-jdk:1.5.6 my-project-assembly copy-test-file ${project.basedir}/static/testFile.txt static ${project.basedir}/target/${project.artifactId}-${project.version}.jar . /deployments java -jar /my-project-assembly/${project.artifactId}-${project.version}.jar 8080 ================================================ FILE: samples/spring-boot-with-jib/src/main/java/io/fabric8/maven/sample/springboot/jib/Application.java ================================================ package io.fabric8.maven.sample.springboot.jib; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } ================================================ FILE: samples/spring-boot-with-jib/src/main/java/io/fabric8/maven/sample/springboot/jib/HelloController.java ================================================ package io.fabric8.maven.sample.springboot.jib; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @RequestMapping("/") public String index() { return "

Greetings from Spring Boot(Powered by JIB)!!

"; } } ================================================ FILE: samples/spring-boot-with-jib/static/testFile.txt ================================================ I should be present ================================================ FILE: samples/test.xml ================================================ build blas blub Test blub ================================================ FILE: samples/volume/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml dmp-sample-volume 0.34-SNAPSHOT io.fabric8 docker-maven-plugin true always true newVolume start pre-integration-test volume-create start stop post-integration-test stop volume-remove ================================================ FILE: samples/zero-config/Dockerfile ================================================ FROM openjdk:jre ARG jar_file=target/dmp-sample-zero-config.jar ARG FOO=${} ADD $jar_file /tmp/zero-config.jar CMD java -cp /tmp/zero-config.jar HelloWorld ================================================ FILE: samples/zero-config/pom.xml ================================================ 4.0.0 io.fabric8.dmp.samples dmp-sample-parent 0.34-SNAPSHOT ../pom.xml io.fabric8.dmp.samples dmp-sample-zero-config jar 0.34-SNAPSHOT ${project.build.directory}/${project.build.finalName}.jar 1.8 1.8 dmp-sample-zero-config io.fabric8 docker-maven-plugin ================================================ FILE: samples/zero-config/src/main/java/HelloWorld.java ================================================ public class HelloWorld { public static void main(String[] args) { System.out.println("Hello world !"); } } ================================================ FILE: src/main/asciidoc/inc/_authentication.adoc ================================================ [[authentication]] = Authentication When pulling (via the `autoPull` mode of `{plugin}:start`) or pushing image, it might be necessary to authenticate against a Docker registry. There are six different locations searched for credentials. In order, these are: * Providing system properties `docker.username` and `docker.password` from the outside. * Providing system properties `registry.username` and `registry.password` from the outside. * Using a `` section in the plugin configuration with `` and `` elements. * Using OpenShift configuration in `~/.config/kube` * Using a `` configuration in `~/.m2/settings.xml` * Login into a registry with `docker login` (credentials in a credential helper or in `~/.docker/config.json`) Using the username and password directly in the `pom.xml` is not recommended since this is widely visible. This is easiest and transparent way, though. Using an `` is straight forward: [source,xml] ---- consol/tomcat-7.0 ... jolokia s!cr!t ---- The system property provided credentials are a good compromise when using CI servers like Jenkins. You simply provide the credentials from the outside: .Example [source, sh, subs="+attributes"] ---- mvn -Ddocker.username=jolokia -Ddocker.password=s!cr!t {plugin}:push ---- The most _mavenish_ way is to add a server to the Maven settings file `~/.m2/settings.xml`: .Example [source,xml] ---- docker.io jolokia s!cr!t .... ---- The server id must specify the registry to push to/pull from, which by default is central index `docker.io` (or `index.docker.io` / `registry.hub.docker.com` as fallbacks). Here you should add your docker.io account for your repositories. If you have multiple accounts for the same registry, the second user can be specified as part of the ID. In the example above, if you have a second account 'fabric8io' then use an `docker.io/fabric8io` for this second entry. I.e. add the username with a slash to the id name. The default without username is only taken if no server entry with a username appended id is chosen. The most _secure_ way is to rely on docker's credential store or credential helper and read confidential information from an external credentials store, such as the native keychain of the operating system. Follow the instruction on https://docs.docker.com/engine/reference/commandline/login/#credentials-store[the docker login documentation]. As a final fallback, this plugin consults `$DOCKER_CONFIG/config.json` if `DOCKER_CONFIG` is set, or `~/.docker/config.json` if not, and reads credentials stored directly within this file. This unsafe behavior happened when connecting to a registry with the command `docker login` from the command line with older versions of docker (pre 1.13.0) or when docker is not configured to use a https://docs.docker.com/engine/reference/commandline/login/#credentials-store[credential store]. == Pull vs. Push Authentication The credentials lookup described above is valid for both push and pull operations. In order to narrow things down, credentials can be provided for pull or push operations alone: In an `` section a sub-section `` and/or `` can be added. In the example below the credentials provider are only used for image push operations: .Example [source,xml] ---- consol/tomcat-7.0 ... jolokia s!cr!t ---- When the credentials are given on the command line as system properties, then the properties `docker.pull.username` / `docker.pull.password` and `docker.push.username` / `docker.push.password` are used for pull and push operations, respectively (when given). Either way, the standard lookup algorithm as described in the previous section is used as fallback. == OpenShift Authentication When working with the default registry in OpenShift, the credentials to authenticate are the OpenShift username and access token. So, a typical interaction with the OpenShift registry from the outside is: ---- oc login ... mvn -Ddocker.registry=docker-registry.domain.com:80/default/myimage \ -Ddocker.username=$(oc whoami) \ -Ddocker.password=$(oc whoami -t) ---- (note, that the image's username part ("default" here") must correspond to an OpenShift project with the same name to which you currently connected account has access). This can be simplified by using the system property `docker.useOpenShiftAuth` in which case the plugin does the lookup. The equivalent to the example above is ---- oc login ... mvn -Ddocker.registry=docker-registry.domain.com:80/default/myimage \ -Ddocker.useOpenShiftAuth ---- Alternatively the configuration option `` can be added to the `` section. For dedicated _pull_ and _push_ configuration the system properties `docker.pull.useOpenShiftAuth` and `docker.push.useOpenShiftAuth` are available as well as the configuration option `` in an `` or `` section within the `` configuration. If `useOpenShiftAuth` is enabled then the OpenShift Konfiguration will be looked up in `$KUBECONFIG` or, if this environment variable is not set, in `~/.kube/config`. [[password-encryption]] == Password encryption Regardless which mode you choose you can encrypt password as described in the http://maven.apache.org/guides/mini/guide-encryption.html[Maven documentation]. Assuming that you have setup a _master password_ in `~/.m2/security-settings.xml` you can create easily encrypt passwords: .Example [source,bash] ---- $ mvn --encrypt-password Password: {QJ6wvuEfacMHklqsmrtrn1/ClOLqLm8hB7yUL23KOKo=} ---- This password then can be used in `authConfig`, `docker.password` and/or the `` setting configuration. However, putting an encrypted password into `authConfig` in the `pom.xml` doesn't make much sense, since this password is encrypted with an individual master password. [[extended-authentication]] == Extended Authentication Some docker registries require additional steps to authenticate. link:https://docs.aws.amazon.com/AmazonECR/latest/userguide/ECR_GetStarted.html[Amazon ECR] requires using an IAM access key to obtain temporary docker login credentials. The `docker:push` and `docker:pull` goals automatically execute this exchange for any registry of the form __ *.dkr.ecr.* __ *.amazonaws.com*, unless the `skipExtendedAuth` configuration (`docker.skip.extendedAuth` property) is set true. Note that for an ECR repository with URI `123456789012.dkr.ecr.eu-west-1.amazonaws.com/example/image` the d-m-p's `docker.registry` should be set to `123456789012.dkr.ecr.eu-west-1.amazonaws.com` and `example/image` is the `` of the image. You can use any IAM access key with the necessary permissions in any of the locations mentioned above except `~/.docker/config.json`. Use the IAM *Access key ID* as the username and the *Secret access key* as the password. In case you're using temporary security credentials provided by the AWS Security Token Service (AWS STS), you have to provide the *security token* as well. To do so, either specify the `docker.auth` system property or provide an `` element alongside username & password in the `authConfig`. d-m-p will attempt to read AWS credentials from some well-known spots in case there is no explicit configuration: * it will pick up ENV variables link:https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html[as documented for the AWS CLI] * it will pick up temporary credentials of link:https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html[the IAM role of an EC2 instance] * it will pick up temporary credentials of link:https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html[the IAM role of a fargate task (OR ECS with EC2 with ECS_AWSVPC_BLOCK_IMDS as "true")] If any of these authentication information is accessible, it will be used. [NOTE] ==== For a more complete, robust and reliable authentication experience, you can add the AWS SDK for Java as a dependency. [source,xml] ---- io.fabric8 docker-maven-plugin com.amazonaws aws-java-sdk-core 1.11.707 ---- This extra dependency allows the usage of all link:https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/credentials.html[options] that the AWS default credential provider chain provides. If the AWS SDK is found in the classpath, it takes precedence over the custom AWS credentials lookup mechanisms listed above. ==== ================================================ FILE: src/main/asciidoc/inc/_docker-build.adoc ================================================ [[docker:build]] == *docker:build* This goal will build all images which have a `` configuration section, or, if the global configuration variable `filter` (property: `docker.filter`) is set, only the images contained in this variable (comma separated) will be built. include::build/_overview.adoc[] [[build-configuration]] === Configuration include::build/_configuration.adoc[] [[build-assembly]] === Assembly include::build/_assembly.adoc[] [[misc-startup]] === Startup Arguments include::misc/_startup.adoc[] [[build-buildargs]] === Build Args include::build/_buildargs.adoc[] [[build-healthcheck]] === Healthcheck include::build/_healthcheck.adoc[] ================================================ FILE: src/main/asciidoc/inc/_docker-logs.adoc ================================================ [[docker:logs]] == *docker:logs* With this goal it is possible to print out the logs of containers started from images configured in this plugin. By default only the latest container started is printed, but this can be changed with a property. The format of the log output is influenced by run configuration of the configured images. The following system properties can the behaviour of this goal: .Logging options [cols="1,5"] |=== | Property | Description | *docker.logAll* | If set to `true` the logs of all containers created from images configured for this plugin are printed. The container id is then prefixed before every log line. These images can contain many containers which are already stopped. It is probably a better idea to use `docker logs` diretly from the command line. | *docker.follow* | If given will wait for subsequent log output until CRTL-C is pressed. This is similar to the behaviour of `docker logs -f` (or `tail -f`). | *docker.filter* | Filter to restrict the set of images for which log should be fetched. This can be a comma separated list of image or alias names. | *docker.logDate* | Date format to use. See "<>" for available formats. |=== .Example [source, sh, subs="+attributes"] ---- $ mvn {plugin}:logs -Ddocker.follow -Ddocker.logDate=DEFAULT ---- ================================================ FILE: src/main/asciidoc/inc/_docker-push.adoc ================================================ [[docker:push]] == *docker:push* include::push/_overview.adoc[] include::push/_configuration.adoc[] ================================================ FILE: src/main/asciidoc/inc/_docker-remove.adoc ================================================ [[docker:remove]] == *docker:remove* This goal can be used to clean up images. By default all images with a build configuration are removed. You can tune this by setting the property `removeMode` (property: `docker.removeMode`) to one of the following values: .removeMode Values [cols="1,5"] |=== | Value | Description | `build` | All images with a <> | `run` | All images without a <> | `all` | All configured images | `data` | All data images, which are images without a <>. |=== Previously, this could be tuned also by providing the property `removeAll` which indicates to remove all images managed by this build. Otherwise only data images were delete before 0.24.0. `removeAll` is deprecated and will be removed soone. Please use `removeMode` instead. As with the other goals, the configuration `image` can be used to tune the images to remove. All containers belonging to the images are removed as well as the all tags assigned to this image Considering three images 'db','tomcat' and 'data' where 'data' is the only image with a build configuration: * `mvn {plugin}:remove` will remove 'data' * `mvn -Ddocker.removeMode=all {plugin}:remove` will remove all three images * `mvn -Ddocker.filter=data,tomcat {plugin}:remove` will remove 'data' * `mvn -Ddocker.filter=data,tomcat -Ddocker.removeMode=all {plugin}:remove` will remove 'data' and 'tomcat' .Remove options [cols="1,5,1"] |=== | Element | Description | Property | *skipTag* | If set to `true` this plugin won't remove any tags | `docker.skip.tag` | *removeNamePattern* | If a list of <> is provided, any images matching the patterns will be removed, independently of whether there is an <> marked for removal. | `docker.removeNamePattern` |=== ================================================ FILE: src/main/asciidoc/inc/_docker-save.adoc ================================================ [[docker:save]] == *docker:save* The `{plugin}:save` target saves an image defined in the build configuration to a local file, analogous to `docker save`. If the option `saveFile` is not set, the file name is calculated automatically: * If `saveAlias` is used then the file is stored as `target/-.tar.gz` * Otherwise the archive is stored as `target/-.tar.gz` Please note that the exported image contains all image layers and can be quite large (also, it takes a bit to export the image). .Controlling image compression The file name extension is used to select a compression method for the output. [cols="3,2,1"] |=== | Extensions | Compression | Type | .tar or unrecognized | No compression | .tar | .tar.gz, .tgz | GZIP compression | .tar.gz | .tar.bz, .tar.bz2, .tar.bzip2 | BZIP2 compression | .tar.bz |=== .Attaching the saved image as an artifact If `saveClassifier` is set, the saved archive will be attached to the project using the provided classifier and the type determined from the file name. The placeholder `%a` will be replaced with the image alias. Note that using overriding the default to use `docker` or `docker-%a` may lead to a conflict if a source archive is also attached with <<{plugin}:source>>. .Save options [cols="1,5,1"] |=== | Element | Description | Property | *saveName* | The name of the image configuration to save. Must not be used together with `alias`. | `docker.save.name` | *saveAlias* | The alias of the image configuration to save. Must not be used together with `name`. | `docker.save.alias` | *saveFile* | The filename to save. | `docker.save.file` or `docker.file` or `file` | *saveClassifier* | If set, attach the the saved archive to the project with the provided classifier. A placeholder of `%a` will be replaced with the image alias. | `docker.save.classifier` | *skipSave* | A boolean flag whether to skip execution of the goal. | `docker.skip.save` |=== ================================================ FILE: src/main/asciidoc/inc/_docker-source.adoc ================================================ [[docker:source]] == *docker:source* The `{plugin}:source` target can be used to attach a docker build archive containing the Dockerfile and all added files to the Maven project with a certain classifier. It reuses the configuration from <<{plugin}:build>>. By default, only the first image configuration is used for creating the source archive. You can export all image configurations by setting the `sourceMode` configuration to `all`: .Export all image configs [source,xml] ---- docker-maven-plugin all ---- For exporting all image configurations, `{plugin}:source` uses the image's link:image-configuration.md[alias] as part of the classifier, so it is mandatory that the alias is set for this goal to work when all images should be exported this way. The classifier is calculated as `docker-` so when the alias is set to `service`, then the classifier is `docker-service`. If you only export the first image configuration (which is the default), then the classifier is just `docker` (without alias). `{plugin}:source` can be attached to a Maven execution phase, which is `generate-sources` by default. For example, this configuration will attach the docker build archive to the artifacts to store in the repository: .Example [source,xml] ---- docker-maven-plugin sources source ---- If not bound to an execution phase, `docker:source` requires that the artifact has been created so you call it best together with `package` ================================================ FILE: src/main/asciidoc/inc/_docker-start.adoc ================================================ [[docker:start]] == *docker:start* include::start/_overview.adoc[] [[start-configuration]] === Configuration include::start/_configuration.adoc[] [[misc-env]] === Environment and Labels include::misc/_env.adoc[] [[start-port-mapping]] === Port Mapping include::start/_port-mapping.adoc[] [[start-links]] === Links include::start/_links.adoc[] [[network-configuration]] === Network include::start/_network.adoc[] [[start-depends-on]] === Depends-On include::start/_depends-on.adoc[] [[start-restart]] === Restart Policy include::start/_restart.adoc[] [[start-volumes]] === Volumes include::start/_volumes.adoc[] [[start-wait]] === Wait include::start/_wait.adoc[] [[start-logging]] === Logging include::start/_logging.adoc[] ================================================ FILE: src/main/asciidoc/inc/_docker-stop.adoc ================================================ [[docker:stop]] == *docker:stop* Stops and removes a docker container. This goal stops every container started with `<{plugin}:start>` either during the same build (e.g. when bound to lifecycle phases when doing integration tests) or for containers created by a previous call to `<{plugin}:start>` If called within the same build run, only the containers that were explicitly started during the run will be stopped. Existing containers started using `{plugin}:start` for the project will not be affected. If called as a separate invocation, the plugin will stop and remove any container it finds whose image is defined in the project's configuration. Any existing containers found running whose image name matches but were not started by the plugin will not be affected. In case the naming strategy for an image is `alias` (i.e. the container name is set to the given alias), then only the container with this alias is stopped. Other containers originating from the same image are not touched. It should be noted that any containers created prior to version `0.13.7` of the plugin may not be stopped correctly by the plugin because the label needed to tie the container to the project may not exist. Should this happen, you will need to use the Docker CLI to clean up the containers and/or use the `docker.allContainers` option listed below. For tuning what should happen when stopping there are four global parameters which are typically used as system properties: `allContainers`, `keepContainer`, `keepRunning` and `removeVolumes`. .Stop configuration [cols="1,5,1"] |=== | Element | Description | Parameter | *allContainers* | Stops and removes any container that matches an image defined in the current project's configuration. This was the default behavior of the plugin prior up to version 0.13.6 | `docker.allContainers` | <> | Default pattern that <<{plugin}:start>> uses for naming containers when they are created. See <> for details. This should match the setting for <<{plugin}:start>> goals if the goals are configured in separate executions. | `docker.containerNamePattern` | *keepContainer* | If set to `true` not destroy container after they have been stopped. Default is false. | `docker.keepContainer` | *keepRunning* | If set to `true` actually don't stop the container. This apparently makes only sense when used on the command line when doing integration testing (i.e. calling `{plugin}:stop` during a lifecycle binding) so that the container are still running after an integration test. This is useful for analysis of the containers (e.g. by entering it with `docker exec`). | `docker.keepRunning` | *removeVolumes* | If set to `true` will remove any volumes associated to the container as well. This option will be ignored if either `keepContainer` or `keepRunning` are true. | `docker.removeVolumes` | *stopNamePattern* | If a list of <> is provided, any containers matching the patterns will be stopped and removed (depending on the values of `keepContainer` and `keepRunning`), independently of whether there is an <>. | `docker.stopNamePattern` |=== .Example [source,sh] ---- $ mvn -Ddocker.keepRunning clean install ---- ================================================ FILE: src/main/asciidoc/inc/_docker-tag.adoc ================================================ [[docker:tag]] == *docker:tag* The `{plugin}:tag` tags an image so that it becomes part of a repository. You can use it to tag an already built image. Here is an example of it's usage: [source] ---- ~/work/repos/docker-maven-plugin/samples/zero-config : $ mvn docker:tag -Ddocker.image.tag=0.9.0 [INFO] Scanning for projects... [INFO] [INFO] -----------< io.fabric8.dmp.samples:demp-sample-zero-config >----------- [INFO] Building demp-sample-zero-config 0.33-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- docker-maven-plugin:0.33-SNAPSHOT:tag (default-cli) @ demp-sample-zero-config --- [INFO] DOCKER> Tagging image samples/demp-sample-zero-config:0.9.0 successful! [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.155 s [INFO] Finished at: 2020-06-27T14:05:33+05:30 [INFO] ------------------------------------------------------------------------ ~/work/repos/docker-maven-plugin/samples/zero-config : $ docker images | grep 0.9.0 samples/demp-sample-zero-config 0.9.0 ac5c5991505d About an hour ago 479MB ---- .Supported options [cols="1,2,1"] |=== | Element | Description | Property | *tagName* | The name of the new tag. | `docker.image.tag` | *repo* | The repository to tag in. For example, `someuser/someimage`. | `docker.image.repo` |=== ================================================ FILE: src/main/asciidoc/inc/_docker-volume-create.adoc ================================================ [[docker:volume-create]] == *docker:volume-create* This goals creates one or more standalone https://docs.docker.com/engine/tutorials/dockervolumes/[Docker volume], which can be referenced in a <> configuration for linking to a volume during runtime. Each volume has therefore a unique and referenceable name. Beside the volume driver and driver options can be specified. .Example for a volume configuration [source,xml] ---- temp-volume local tmpfs tmpfs size=100m,uid=1000 true ... ---- [[volume-create-configuration]] .Configuration The following options are available when creating volumes: .Volume configuration |=== | Element | Description | *name* | Name of the volume | *driver* | Volume driver to use. By default the driver `local` is used which is created on the local file system. Please refer to your Docker installation which additional drivers are available. | *opts* | Driver specific options passed in as custom `value` where its maps to `key=value` pairs for driver options as they can be provided from the Docker CLI, too. Each volume driver supports different options. The options supported by the `local` driver are the well known http://man7.org/linux/man-pages/man8/mount.8.html[Linux mount options]. |*labels* | Labels given as `value` similar to image labels described in <>. These labels are used to tag the volumes themselves. |=== ================================================ FILE: src/main/asciidoc/inc/_docker-volume-remove.adoc ================================================ [[docker:volume-remove]] == *docker:volume-remove* This goals is the counterpart to <> and removes a volume. Docker volumes are configured outside of Docker images, but can be referenced by them. The configuration is the same as for <> *Example:* [source,xml] ---- temp-volume .... ... ---- [[volume-remove-configuration]] .Configuration The configuration is quite simple. Only the name of the volume to delete is required. .Volume configuration [options="header"] |=== | Element | Description | *name* | Name of the volume |=== ================================================ FILE: src/main/asciidoc/inc/_docker-watch.adoc ================================================ [[docker:watch]] == *docker:watch* include::watch/_overview.adoc[] [[watch-configuration]] include::watch/_configuration.adoc[] ================================================ FILE: src/main/asciidoc/inc/_external-configuration.adoc ================================================ [[external-configuration]] = External Configuration For special configuration needs, there is the possibility to get the runtime and build configuration from places outside the plugin's configuration. This is done with the help of `` configuration sections which at least has a `` subelement. This `` element selects a specific so called "handler" which is responsible for creating the full image configuration. A handler can decide to use the `` and `` configuration which could be provided in addition to this `` section or it can decide to completely ignore any extra configuration option. A handler can also decide to expand this single image configuration to a list of image configurations. The image configurations resulting from such a external configuration are added to the _regular_ `` configurations without an `` section. The available handlers are described in the following. [[property-configuration]] == Properties include::external/_property_configuration.adoc[] [[docker-compose]] == Docker Compose include::external/_docker_compose.adoc[] ================================================ FILE: src/main/asciidoc/inc/_global-configuration.adoc ================================================ [[global-configuration]] = Global configuration Global configuration parameters specify overall behavior like the connection to the Docker host. The corresponding system properties which can be used to set it from the outside are given in parentheses. The docker-maven-plugin uses the Docker remote API so the URL of your Docker Daemon must somehow be specified. The URL can be specified by the dockerHost or machine configuration, or by the `DOCKER_HOST` environment variable. The Docker remote API supports communication via SSL and authentication with certificates. The path to the certificates can be specified by the certPath or machine configuration, or by the `DOCKER_CERT_PATH` environment variable. .Global Configuration [cols="1,5,1"] |=== | Element | Description | Property | *apiVersion* | Use this variable if you are using an older version of docker not compatible with the current default use to communicate with the server. | `docker.apiVersion` | *authConfig* | Authentication information when pulling from or pushing to Docker registry. There is a dedicated section <> for how doing security. | | *autoCreate CustomNetworks* | Create automatically Docker networks during `{plugin}:start` and remove it during `{plugin}:stop` if you provide a custom network in the run configuration of an image. The default is `false`. | `docker.autoCreate` `CustomNetworks` | *autoPull* a| Decide how to pull missing base images or images to start. This option is *deprecated*, please use <> instead. The following values are supported: * `on` or `once`: Automatic download any missing images (default) * `off` : Automatic pulling is switched off always * `always` : Pull images always even when they already exist locally. | `docker.autoPull` | *buildArchiveOnly* a| Skip the actual Docker image build and only create the archive holding the Dockerfile and build context. The following values are supported: * `/path/to/archive` : Create the build tar archive as file with name `/path/to/archive` and then stop without doing the actual image build * `true` (or an empty value) : Skip building the image, but don't copy the generated build archive. * `false` : Build the image. This is the default behaviour. | `docker.buildArchiveOnly` | *certPath* | Path to SSL certificate when SSL is used for communicating with the Docker daemon. These certificates are normally stored in `~/.docker/`. With this configuration the path can be set explicitly. If not set, the fallback is first taken from the environment variable `DOCKER_CERT_PATH` and then as last resort `~/.docker/`. The keys in this are expected with it standard names `ca.pem`, `cert.pem` and `key.pem`. Please refer to the https://docs.docker.com/articles/https[Docker documentation] for more information about SSL security with Docker. | `docker.certPath` | *dockerHost* a| The URL of the Docker Daemon. If this configuration option is not given, then the optional `` configuration section is consulted. The scheme of the URL can be either given directly as `http` or `https` depending on whether plain HTTP communication is enabled or SSL should be used. Alternatively the scheme could be `tcp` in which case the protocol is determined via the IANA assigned port: 2375 for `http` and 2376 for `https`. Finally, Unix sockets are supported by using the scheme `unix` together with the filesystem path to the unix socket. The discovery sequence used by the docker-maven-plugin to determine the URL is: . value of *dockerHost* (`docker.host`) . the Docker host associated with the docker-machine named in ``, i.e. the `DOCKER_HOST` from `docker-machine env`. See <> for more information about Docker machine support. If `` is not set, then no docker-machine detection is used. . the value of the environment variable `DOCKER_HOST`. . `/var/run/docker.sock` if it is a readable socket (Unix & OS X). . `//./pipe/docker_engine` if it is a readable named pipe (Windows) | `docker.host` | *filter* | In order to temporarily restrict the operation of plugin goals this configuration option can be used. Typically this will be set via the system property `docker.filter` when Maven is called. The value can be a single image name (either its alias or full name) or it can be a comma separated list with multiple image names. Any name which doesn't refer an image in the configuration will be ignored. | `docker.filter` | [[image-pull-policy]] *imagePullPolicy* a| Specify whether images should be pull when looking for base images while building or images for starting. This property can take the following values (case insensitive): * `IfNotPresent`: Automatic download any missing images (default) * `Never` : Automatic pulling is switched off always * `Always` : Pull images always even when they already exist locally. By default a progress meter is printed out on the console, which is omitted when using Maven in batch mode (option `-B`). A very simplified progress meter is provided when using no color output (i.e. with `-Ddocker.useColor=false`). | `docker.imagePullPolicy` | *logDate* | Date format which is used for printing out container logs. This configuration can be overwritten by individual run configurations and described below. The format is described in <>. | `docker.logDate` | *logStdout* | For all container logging to standard output if set to `true`, regardless whether a `file` for log output is specified. See also <> | `docker.logStdout` | *machine* | Docker machine configuration. See <> for possible values | | *maxConnections* | Number of parallel connections are allowed to be opened to the Docker Host. For parsing log output, a connection needs to be kept open (as well for the wait features), so don't put that number to low. Default is 100 which should be suitable for most of the cases. | `docker.maxConnections` | *jib* | Delegate Image Build process to https://github.com/GoogleContainerTools/jib[JIB], `false` by default. Note that this option is applicable only for <> and <> goals, other goals won't work if this is enabled (since they dependend on Docker specific features) | `docker.build.jib` | *outputDirectory* | Default output directory to be used by this plugin. The default value is `target/docker` and is only used for the goal `{plugin}:build`. | `docker.target.dir` | *portPropertyFile* | Global property file into which the mapped properties should be written to. The format of this file and its purpose are also described in <>. | | *registry* | Specify globally a registry to use for pulling and pushing images. See <> for details. | `docker.registry` | *skip* | With this parameter the execution of this plugin can be skipped completely. | `docker.skip` | *skipBuild* | If set no images will be build (which implies also _skip.tag_) with `{plugin}:build` | `docker.skip.build` | *skipPush* | If set dont push any images even when `{plugin}:push` is called. | `docker.skip.push` | *skipRun* | If set dont create and start any containers with `{plugin}:start` or `{plugin}:run` | `docker.skip.run` | *skipTag* | If set to `true` this plugin won't add any tags to images that have been built with `{plugin}:build`. + If set to `true` this plugin won't push any tags with `{plugin}:push`. + If set to `true` this plugin won't remove any tags with `{plugin}:remove`. + | `docker.skip.tag` | *skipMachine* | Skip using docker machine in any case | `docker.skip.machine` | *sourceDirectory* | Default directory that contains the assembly descriptor(s) used by the plugin. The default value is `src/main/docker`. This option is only relevant for the `{plugin}:build` goal. | `docker.source.dir` | *useColor* | Whether to use colored log output. By default this is switched on when running on a console, off otherwise. | `docker.useColor` | *verbose* | String attribute for switching on verbose output on standard output (stdout). It takes a comma separated list of string values to switch on various verbosity groups. The currently known groups are: build:: Print out Docker build instructions api:: API calls to the Docker daemons are logged all:: All levels are enabled If you set an empty string (or only e.g. `-Ddocker.verbose`) then the "build" group is enabled. You can also use "true" / "false" to switch on / off verbose logging. Default is that verbose logging is disabled. | `docker.verbose` |=== .Example [source,xml] ---- https://localhost:2376 src/main/dockerCerts true ..... ---- [[docker-machine]] .Docker Machine This plugin supports also Docker machine (which must be installed locally, of course). A Docker machine configuration can be provided with a top-level `` configuration section. This configuration section knows the following options: .Docker Machine Options [cols="1,4"] |=== | Element | Description | *name* | Docker machine's name. Default is `default` | *autoCreate* | if set to `true` then a Docker machine will automatically created. Default is `false`. | *regenerateCertsAfterStart* | if set to `true` then certificates will be regenerated after starting the Docker Machine. This is useful if using the AWS EC2 driver, which will assign machines new IP addresses after each start. Default is `false`. | *createOptions* | Map with options for Docker machine when auto-creating a machine. See the docker machine documentation for possible options. |=== When no Docker host is configured or available as an environment variable, then the configured Docker machine is used. If the machine exists but is not running, it is started automatically. If it does not exists but `autoCreate` is true, then the machine is created and started. Otherwise, an error is printed. Please note, that a machine which has been created because of `autoCreate` gets never deleted by docker-maven-plugin. This needs to be done manually if required. In absence of a `` configuration section the Maven property `docker.machine.name` can be used to provide the name of a Docker machine. Similarly, the property `docker.machine.autoCreate` can be set to true for creating a Docker machine, too. You can use the property `docker.skip.machine` if you want to override the internal detection mechanism to always disable docker machine support. .Example [source,xml] ---- maven true virtualbox 2 ..... ---- ================================================ FILE: src/main/asciidoc/inc/_goals.adoc ================================================ = Maven Goals This plugin supports the following goals which are explained in detail in the next sections. .Plugin Goals [cols="2,3,2"] |=== |Goal | Description | Default Lifecycle Phase |**<<{plugin}:build>>** |Build images |install |**<<{plugin}:start>>** or **<<{plugin}:start,{plugin}:run>>** |Create and start containers |pre-integration-test |**<<{plugin}:stop>>** |Stop and destroy containers |post-integration-test |**<<{plugin}:push>>** |Push images to a registry |deploy |**<<{plugin}:watch>>** |Watch for doing rebuilds and restarts | |**<<{plugin}:remove>>** |Remove images from local docker host |post-integration-test |**<<{plugin}:logs>>** |Show container logs | |**<<{plugin}:source>>** |Attach docker build archive to Maven project |package |**<<{plugin}:save>>** |Save images to a file | |**<<{plugin}:volume-create>>** |Create a volume for containers to share data |pre-integration-test |**<<{plugin}:volume-remove>>** |Remove a volume |post-integration-test |=== Note that all goals are orthogonal to each other. For example in order to start a container for your application you typically have to build its image before. `{plugin}:start` does *not* imply building the image so you should use it then in combination with `{plugin}:build`. ================================================ FILE: src/main/asciidoc/inc/_image-configuration.adoc ================================================ [[image-configuration]] = Image configuration The plugin's configuration is centered around _images_. These are specified for each image within the `` element of the configuration with one `` element per image to use. The `` element can contain the following sub elements: include::image/_configuration.adoc[] Either a `` or `` section must be present (except when you are using the <> mode). These are explained in details in the corresponding goal sections. include::image/_example.adoc[] When using Maven profiles, it can be useful to override settings of a particular image. To facilitate this, the element `` can be used alongside the `` element. Each entry in `` translates to an image configuration where the **alias** of the image is set to the map entry's **key**. The examples above and below produce identical image configurations. include::image/_example_imagesMap.adoc[] include::image/_naming.adoc[] ================================================ FILE: src/main/asciidoc/inc/_implicit-properties.adoc ================================================ = Implicit properties There are some implicit configurations in docker maven plugin that are not so straightforward. These are simply workarouds to get docker-maven-plugin's flow right; just to overcome limitations of Maven and other things. Some of these are mentioned below: * If the only value of the `env` parameter is a docker-maven-plugin internal property which has been set implicitly you have to prefix the property with a single `+` like in `+${docker.container.test.ip}`. This is necessary due to some Maven limitations which simply interpolates a lone, non defined property, to an empty string which can't then be replaced by this plugin after the initial interpolation phase. * When providing port mapping in a format like `host.ip:host.port:80`, you need to prefix property with a single `+`. In this form, the host ip of the container will be placed into a Maven property name host.ip. If docker reports that value to be 0.0.0.0, the value of docker.host.address will be substituted instead. In the event you want to use this form and have the container bind to a specific hostname/ip address, you can declare a Maven property of the same name (host.ip in this example) containing the value to use. host:port works in the same way as described above. ================================================ FILE: src/main/asciidoc/inc/_installation.adoc ================================================ = Installation This plugin is available from Maven central and can be connected to pre- and post-integration phase as seen below. The configuration and available goals are described below. .Example [source,xml,indent=0,subs="verbatim,quotes,attributes"] ---- io.fabric8 docker-maven-plugin {version} .... .... .... start pre-integration-test build start stop post-integration-test stop ---- When working with this plugin you can use an own packaging with a specialized lifecycle in order to keep your pom files small. Three packaging variants are available: * *docker* : This binds `{plugin}:build` to the package phase and `{plugin}:start` / `{plugin}:stop` to the pre- and post-integration phase respectively. Also `{plugin}:push` is bound to the deploy phase. * *docker-build* : Much like the _docker_ packaging, except that there are no integration tests configured by default. * *docker-tar* : Create a so called _Docker tar_ archive which is used as the artifact and which later can be used for building an image. It contains essentially a `Dockerfile` with supporting files. See link:docker-source[{plugin}:source] for more details. These packaging definitions include the _jar_ lifecycle methods so they are well suited for simple Microservice style projects. .Example [source,xml] ---- demo 0.0.1 docker ... io.fabric8 docker-maven-plugin true ... .... ---- This will create the jar (if any), build the Docker images, start the configured Docker containers, runs the integration tests, stops the configured Docker container when you enter `mvn install`. With `mvn deploy` you can additionally push the images to a Docker configuration. Please note the `true` which is mandatory when you use a custom lifecycle. The rest of this manual is now about how to configure the plugin for your images. ================================================ FILE: src/main/asciidoc/inc/_introduction.adoc ================================================ = Introduction This is a Maven plugin for managing Docker images and containers. It focuses on two major aspects for a Docker build integration: == Building Images One purpose of this plugin is to create Docker images holding the actual application. This is done with the <<{plugin}:build>> goal. It is easy to include build artefacts and their dependencies into an image. Several ways for configuring the builds are supported: * An own configuration syntax can be used to create a Dockerfile. For specifying artefacts and other files, the plugin uses the assembly descriptor format from the maven-assembly-plugin to copy over those file into the Docker image. * An external Dockerfile can be specified in which Maven properties can be inserted. This is also the default mode, if only a single image should be built and a top-level `Dockerfile` exists. See <> for details of this zero XML configuration mode. Images that are built with this plugin can be pushed to public or private Docker registries with <<{plugin}:push>>. == Running Containers With this plugin it is possible to run completely isolated integration tests so you don't need to take care of shared resources. Ports can be mapped dynamically and made available as Maven properties to your integration test code. Multiple containers can be managed at once, which can be linked together or share data via volumes. Containers are created and started with the <<{plugin}:start>> goal and stopped and destroyed with the <<{plugin}:stop>> goal. For integration tests both goals are typically bound to the the pre-integration-test and post-integration-test phase, respectively. It is recommended to use the maven-failsafe-plugin for integration testing in order to stop the docker container even when the tests fail. For proper isolation, container exposed ports can be dynamically and flexibly mapped to local host ports. It is easy to specify a Maven property which will be filled in with a dynamically assigned port after a container has been started. This can then be used as parameter for integration tests to connect to the application. == Configuration The plugin configuration contains a global part and a list of image-specific configuration within a `` list, where each image is defined within a `` tag. See <> for an example. The <> contains configuration applicable to all images like the Docker URL or the path to the SSL certificates for communication with the Docker Host. Then, each specific image configuration has three parts: * A general image part containing the image name and alias. * A <<{plugin}:build, >> configuration specifying how images are built * A <<{plugin}:start, >> configuration describing how containers should be created and started. The `` and `` parts are optional and can be omitted. [[example]] == Example In the following examples, two images are specified. One is the official PostgreSQL 9 image from Docker Hub, which internally is referenced with an alias "database". It only has a <<{plugin}:start, >> section which declares that the startup should wait until the given text pattern is matched in the log output. Next is a "service" image, which has a <<{plugin}:build, >> section. It creates an image which has artifacts and dependencies in the `/maven` directory (and which are specified with an assembly descriptor). Additionally, it specifies the startup command for the container, which in this example fires up a microservice from a jar file copied over via the assembly descriptor. It also exposes port 8080. In the `` section this port is mapped to a dynamically chosen port and then assigned to the Maven property `${tomcat.port}`. This property could be used, for example, by an integration test to access this microservice. An important part is the `` section which indicates that the image with the alias of "database" is linked into the "service" container, which can access the internal ports in the usual Docker way (via environment variables prefixed with `DB_`). Images can be specified in any order and the plugin will take care of the proper startup order (and will bail out if it detects circular dependencies). [source,xml,indent=0,subs="verbatim,quotes"] .Example plugin configuration ---- service fabric8/docker-demo:${project.version} java:8 docker-assembly.xml java -jar /maven/service.jar tomcat.port:8080 http://localhost:${tomcat.port}/access database:db database postgres:9 database system is ready to accept connections ---- <1> Image configuration for a Java service with alias "service" and name `fabric8/docker-demo:${project.version}` <2> <<{plugin}:build,build configuration>> defines how a Docker image should be created <3> Base image, in this case `java:8` <4> Content of the image can be specified with an <> <5> <> to run when a container is created. <6> <<{plugin}:start,Run configuration>> defines how a container should be created from this image <7> <> defines how container ports should be mapped to host ports <8> <> section which is a readiness check when starting the service <9> <> describes how this service's container is linked to the database container <10> Second image is a plain database image which is only needed for running (hence there is no `` section). The alias is used in the network link section above <11> Wait until the corresponding output appears on stdout when starting the Docker container. == Features Some other highlights, in random order: * Auto pulling of images with a progress indicator * Waiting for a container to startup based on time, the reachability of an URL, or a pattern in the log output * Support for SSL <> and OpenShift credentials * Docker machine support * Flexible registry handling (i.e. registries can be specified as metadata) * Specification of <> registry passwords for push and pull in ~/.m2/settings.xml (i.e., outside the pom.xml) * Color output * <<{plugin}:watch,Watching>> on project changes and automatic recreation of image * <> as alternative to the XML configuration * Support for Docker daemons accepting http or https request via TCP and for Unix sockets ================================================ FILE: src/main/asciidoc/inc/_links.adoc ================================================ = Further reading * Examples: ** https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/examples.md[Examples] are below `samples/` and contain example setups which you can use as blueprints for your own projects. ** A https://github.com/fabric8io/shootout-docker-maven[Shootout] for comparing docker maven plugins ** Another https://github.com/fabric8io/docker-maven-sample[sample project] with a Microservice and a Database. * https://github.com/fabric8io/docker-maven-plugin/blob/master/doc/changelog.md[ChangeLog] has the release history of this plugin. * https://github.com/fabric8io/docker-maven-plugin/blob/master/CONTRIBUTING.md[Contributing] explains how you can contribute to this project. Pull requests are highly appreciated! ================================================ FILE: src/main/asciidoc/inc/_registry.adoc ================================================ [[registry]] = Registry handling Docker uses registries to store images. The registry is typically specified as part of the name. I.e. if the first part (everything before the first `/`) contains a dot (`.`) or colon (`:`) this part is interpreted as an address (with an optionally port) of a remote registry. This registry (or the default `docker.io` if no registry is given) is used during push and pull operations. This plugin follows the same semantics, so if an image name is specified with a registry part, this registry is contacted. Authentication is explained in the next <<_authentication,section>>. There are some situations however where you want to have more flexibility for specifying a remote registry. This might be because you do not want to hard code a registry into `pom.xml` but provide it from the outside with an environment variable or a system property. This plugin supports various ways of specifying a registry: * If the image name contains a registry part, this registry is used unconditionally and can not be overwritten from the outside. * If an image name doesn't contain a registry, then by default the default Docker registry `docker.io` is used for push and pull operations. But this can be overwritten through various means: ** If the `` configuration contains a `` subelement this registry is used. ** Otherwise, a global configuration element `` is evaluated which can be also provided as system property via `-Ddocker.registry`. ** Finally an environment variable `DOCKER_REGISTRY` is looked up for detecting a registry. This registry is used for pulling (i.e. for autopull the base image when doing a `{plugin}:build`) and pushing with `{plugin}:push`. However, when these two goals a are combined on the command line like in `mvn -Ddocker.registry=myregistry:5000 package {plugin}:build {plugin}:push` the same registry is used for both operation. For a more fine grained control, separate registries for _pull_ and _push_ can be specified. * In the plugin's configuration with the parameters `` and ``, respectively. * With the system properties `docker.pull.registry` and `docker.push.registry`, respectively. .Example [source,xml] ---- docker.jolokia.org:443 jolokia/jolokia-java docker.ro14nd.de .... postgresql .... docker.example.com:5000/another/server ---- There is some special behaviour when using an externally provided registry like described above: * When _pulling_, the image pulled will be also tagged with a repository name *without* registry. The reasoning behind this is that this image then can be referenced also by the configuration when the registry is not specified anymore explicitly. * When _pushing_ a local image, temporarily a tag including the registry is added and removed after the push. This is required because Docker can only push registry-named images. ================================================ FILE: src/main/asciidoc/inc/build/_assembly.adoc ================================================ The `` element within `` is has an XML struture and defines how build artifacts and other files can enter the Docker image. [[config-image-build-assembly]] .Assembly Configuration (< >> : < >>) [cols="1,5"] |=== | Element | Description | *name* | Assembly name, which is `maven` by default. This name is used for the archives and directories created during the build. This directory holds the files specified by the assembly. If an <> is used than this name is also the relative directory which contains the assembly files. | *targetDir* | Directory under which the files and artifacts contained in the assembly will be copied within the container. The default value for this is `/`, so `/maven` if *name* is not set to a different value. This option has no meaning when an <> is used. | <> | Inlined assembly descriptor as described in <> below. | <> | Path to an assembly descriptor file, whose format is described <> below. | <> | Alias to a predefined assembly descriptor. The available aliases are also described in <> below. | *dockerFileDir* | Directory containing an external Dockerfile. _This option is deprecated, please use directly in the section_. | *exportTargetDir* | Specification whether the `targetDir` should be exported as a volume. This value is `true` by default except in the case the `targetDir` is set to the container root (`/`). It is also `false` by default when a base image is used with `from` since exporting makes no sense in this case and will waste disk space unnecessarily. | *ignorePermissions* | Specification if existing file permissions should be ignored when creating the assembly archive with a mode `dir`. This value is `false` by default. _This property is deprecated, use a `permissions` of `ignore` instead._ | *mode* a| Mode how the how the assembled files should be collected: * `dir` : Files are simply copied (default), * `tar` : Transfer via tar archive * `tgz` : Transfer via compressed tar archive * `zip` : Transfer via ZIP archive The archive formats have the advantage that file permission can be preserved better (since the copying is independent from the underlying files systems), but might triggers internal bugs from the Maven assembler (as it has been reported in https://github.com/fabric8io/docker-maven-plugin/issues/171[#171]) | *permissions* a| Permission of the files to add: * `ignore` to use the permission as found on files regardless on any assembly configuration * `keep` to respect the assembly provided permissions, `exec` for setting the executable bit on all files (required for Windows when using an assembly mode `dir`) * `auto` to let the plugin select `exec` on Windows and `keep` on others. `keep` is the default value. | *tarLongFileMode* | Sets the TarArchiver behaviour on file paths with more than 100 characters length. Valid values are: "warn"(default), "fail", "truncate", "gnu", "posix", "posix_warn" or "omit" | [[config-image-build-assembly-user]] *user* | User and/or group under which the files should be added. The user must already exist in the base image. It has the general format `user[:group[:run-user]]`. The user and group can be given either as numeric user- and group-id or as names. The group id is optional. If a third part is given, then the build changes to user `root` before changing the ownerships, changes the ownerships and then change to user `run-user` which is then used for the final command to execute. This feature might be needed, if the base image already changed the user (e.g. to 'jboss') so that a `chown` from root to this user would fail. (_**This third user part has been marked as deprecated and will not be supported in future versions of this plugin.**_) For example, the image `jboss/wildfly` use a "jboss" user under which all commands are executed. Adding files in Docker always happens under the UID root. These files can only be changed to "jboss" is the `chown` command is executed as root. For the following commands to be run again as "jboss" (like the final `standalone.sh`), the plugin switches back to user `jboss` (this is this "run-user") after changing the file ownership. For this example a specification of `jboss:jboss:jboss` would be required. |=== In the event you do not need to include any artifacts with the image, you may safely omit this element from the configuration. [[build-assembly-descriptor]] ==== Assembly Descriptor With using the `inline`, `descriptor` or `descriptorRef` option it is possible to bring local files, artifacts and dependencies into the running Docker container. A `descriptor` points to a file describing the data to put into an image to build. It has the same http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html[format] as for creating assemblies with the http://maven.apache.org/plugins/maven-assembly-plugin[maven-assembly-plugin] with following exceptions: * `` are ignored, the assembly will allways use a directory when preparing the data container (i.e. the format is fixed to `dir`) * The `` is ignored since only a single assembly descriptor is used (no need to distinguish multiple descriptors) Also you can inline the assembly description with a `inline` description directly into the pom file. Adding the proper namespace even allows for IDE autocompletion. As an example, refer to the profile `inline` in the `data-jolokia-demo` 's pom.xml. Alternatively `descriptorRef` can be used with the name of a predefined assembly descriptor. The following symbolic names can be used for `descriptorRef`: [[build-assembly-descriptor-refs]] .Predefined Assembly Descriptors [cols="1,3"] |=== | Assembly Reference | Description | *artifact-with-dependencies* | Attaches project's artifact and all its dependencies. Also, when a `classpath` file exists in the target directory, this will be added to. | *artifact* | Attaches only the project's artifact but no dependencies. | *project* | Attaches the whole Maven project but with out the `target/` directory. | *rootWar* | Copies the artifact as `ROOT.war` to the exposed directory. I.e. Tomcat will then deploy the war under the root context. |=== .Example [source,xml] ---- artifact-with-dependencies ..... ---- will add the created artifact with the name `${project.build.finalName}.${artifact.extension}` and all jar dependencies in the the `targetDir` (which is `/maven` by default). All declared files end up in the configured `targetDir` (or `/maven` by default) in the created image. .Maven peculiarities when including the artifact If the assembly references the artifact to build with this pom, it is required that the `package` phase is included in the run. Otherwise the artifact file, can't be found by `docker:build`. This is an old https://issues.apache.org/jira/browse/MASSEMBLY-94[outstanding issue] of the assembly plugin which probably can't be fixed because of the way how Maven works. We tried hard to workaround this issue and in 90% of all cases, you won't experience any problem. However, when the following warning happens which might lead to the given error: [source] ---- [WARNING] Cannot include project artifact: io.fabric8:helloworld:jar:0.20.0; it doesn't have an associated file or directory. [WARNING] The following patterns were never triggered in this artifact inclusion filter: o 'io.fabric8:helloworld' [ERROR] DOCKER> Failed to create assembly for docker image (with mode 'dir'): Error creating assembly archive docker: You must set at least one file. ---- then you have two options to fix this: * Call `mvn package {plugin}:build` to explicitly run "package" and "docker:build" in a chain. * Bind `build` to an to an execution phase in the plugin's definition. By default `{plugin}:build` will bind to the `install` phase is set in an execution. Then you can use a plain `mvn install` for building the artifact and creating the image. [source,xml] ---- docker-build build ---- .Example In the following example a dependency from the pom.xml is included and mapped to the name `jolokia.war`. With this configuration you will end up with an image, based on `busybox` which has a directory `/maven` containing a single file `jolokia.war`. This volume is also exported automatically. [source,xml] ---- org.jolokia:jolokia-war . jolokia.war ---- Another container can now connect to the volume an 'mount' the `/maven` directory. A container from `consol/tomcat-7.0` will look into `/maven` and copy over everything to `/opt/tomcat/webapps` before starting Tomcat. If you are using the `artifact` or `artifact-with-dependencies` descriptor, it is possible to change the name of the final build artifact with the following: .Example [source,xml] ---- your-desired-final-name ... ---- Please note, based upon the following documentation listed http://maven.apache.org/pom.html#BaseBuild_Element[here], there is no guarantee the plugin creating your artifact will honor it in which case you will need to use a custom descriptor like above to achieve the desired naming. Currently the `jar` and `war` plugins properly honor the usage of `finalName`. ================================================ FILE: src/main/asciidoc/inc/build/_buildargs.adoc ================================================ [[property-buildargs]] As described in section <> for external Dockerfiles https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables-build-arg[Docker build arg] can be used. In addition to the configuration within the plugin configuration you can also use properties to specify them: * Set a system property when running Maven, eg.: `-Ddocker.buildArg.http_proxy=http://proxy:8001`. This is especially useful when using predefined Docker arguments for setting proxies transparently. * Set a project property within the `pom.xml`, eg.: .Example [source,xml] ---- myValue ---- Please note that the system property setting will always override the project property. Also note that for all properties which are not Docker https://docs.docker.com/engine/reference/builder/#arg[predefined] properties, the external Dockerfile must contain an `ARGS` instruction. ================================================ FILE: src/main/asciidoc/inc/build/_configuration.adoc ================================================ All build relevant configuration is contained in the `` section of an image configuration. The following configuration options are supported: [[config-image-build]] .Build configuration (< >>) [cols="1,5"] |=== | Element | Description | <> | specifies the assembly configuration as described in <> | <> | Map specifying the value of https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables-build-arg[Docker build args] which should be used when building the image with an external Dockerfile which uses build arguments. The key-value syntax is the same as when defining Maven properties (or `labels` or `env`). This argument is ignored when no external Dockerfile is used. Build args can also be specified as properties as described in <> | *buildOptions* | Map specifying the build options to provide to the docker daemon when building the image. These options map to the ones listed as query parameters in the https://docs.docker.com/engine/reference/api/docker_remote_api_v1.24/#build-image-from-a-dockerfile[Docker Remote API] and are restricted to simple options (e.g.: memory, shmsize). If you use the respective configuration options for build options natively supported by the build configuration (i.e. `squash`, `noCache`, `cleanup=remove` for buildoption `forcerm=1` and `args` for build args) then these will override any corresponding options given here. The key-value syntax is the same as when defining environment variables or labels as described in <>. | *cleanup* | Cleanup dangling (untagged) images after each build (including any containers created from them). Default is `try` which tries to remove the old image, but doesn't fail the build if this is not possible because e.g. the image is still used by a running container. Use `remove` if you want to fail the build and `none` if no cleanup is requested. | [[context-dir]]*contextDir* | Path to a directory used for the build's context. You can specify the `Dockerfile` to use with *dockerFile*, which by default is the Dockerfile found in the `contextDir`. The Dockerfile can be also located outside of the `contextDir`, if provided with an absolute file path. See <> for details. | <> | A command to execute by default (i.e. if no command is provided when a container for this image is started). See <> for details. | *compression* | The compression mode how the build archive is transmitted to the docker daemon (`{plugin}:build`) and how docker build archives are attached to this build as sources (`{plugin}:source`). The value can be `none` (default), `gzip` or `bzip2`. | *dockerFile* | Path to a `Dockerfile` which also triggers _Dockerfile mode_. See <> for details. | *dockerFileDir* (_deprecated_ in favor of *<>*) | Path to a directory holding a `Dockerfile` and switch on _Dockerfile mode_. See <> for details. _This option is deprecated in favor of _contextDir_ and will be removed for the next major release_. | *dockerArchive* | Path to a saved image archive which is then imported. See <> for details. | <> | An entrypoint allows you to configure a container that will run as an executable. See <> for details. | <> | The environments as described in <>. | *filter* | Enable and set the delimiters for property replacements. By default properties in the format `${..}` are replaced with Maven properties. You can switch off property replacement by setting this property to `false`. When using a single char like `@` then this is used as a delimiter (e.g `@...@`). See <> for more details. | [[build-config-from]]*from* | The base image which should be used for this image. If not given this default to `busybox:latest` and is suitable for a pure data image. ifeval::["{plugin}" == "fabric8"] In case of an <> this parameter specifies the S2I Builder Image to use, which by default is `fabric8/s2i-java:latest`. See also <> how to add additional properties for the base image. endif::[] | [[build-config-from-ext]]**fromExt** a| Extended definition for a base image. This field holds a map of defined in `value` format. The known keys are: * `` : Name of the base image ifeval::["{plugin}" == "fabric8"] * `` : Kind of the reference to the builder image when in S2I build mode. By default its `ImageStreamTag` but can be also `ImageStream`. An alternative would be `DockerImage` * `` : Namespace where this builder image lives. endif::[] A provided `` takes precedence over the name given here. This tag is useful for extensions of this plugin like the https://maven.fabric8.io[fabric8-maven-plugin] which can evaluate the additional information given here. | <> | Definition of a health check as described in <> | *imagePullPolicy* | Specific pull policy for the base image. This overwrites any global pull policy. See the globale configuration option <> for the possible values and the default. | [[build-config-load-name-pattern]]*loadNamePattern* a| Scan the archive specified in `dockerArchive` and find the actual repository and tag in the archive that matches this <>. After loading the archive, link the <> configured in the POM to the repository and tag matched in the archive. | <> | Labels as described in <>. | *maintainer* | The author (`MAINTAINER`) field for the generated image | *noCache* | Don't use Docker's build cache. This can be overwritten by setting a system property `docker.noCache` when running Maven. | *squash* | Squash newly built layers into a single new layer. This can be overwritten by setting a system property `docker.squash` when running Maven. | *cacheFrom* | A list of `` elements specifying image names to use as cache sources. | *optimise* | if set to true then it will compress all the `runCmds` into a single `RUN` directive so that only one image layer is created. | *ports* | The exposed ports which is a list of `` elements, one for each port to expose. Whitespace is trimmed from each element and empty elements are ignored. The format can be either pure numerical ("8080") or with the protocol attached ("8080/tcp"). | *shell* | Shell to be used for the *runCmds*. It contains *arg* elements which are defining the executable and its params. | *runCmds* | Commands to be run during the build process. It contains *run* elements which are passed to the shell. Whitespace is trimmed from each element and empty elements are ignored. The run commands are inserted right after the assembly and after *workdir* into the Dockerfile. This tag is not to be confused with the `` section for this image which specifies the runtime behaviour when starting containers. | *skip* | if set to true disables building of the image. This config option is best used together with a maven property | *skipPush* | if set to true disables pushing of the image. This config option is best used together with a maven property | *skipTag* | If set to `true` this plugin won't add any tags to images. Property: `docker.skip.tag` | *tags* | List of additional `tag` elements with which an image is to be tagged after the build. Whitespace is trimmed from each element and empty elements are ignored. | *user* | User to which the Dockerfile should switch to the end (corresponds to the `USER` Dockerfile directive). | *volumes* | List of `volume` elements to create a container volume. Whitespace is trimmed from each element and empty elements are ignored. | *workdir* | Directory to change to when starting the container. |=== From this configuration this Plugin creates an in-memory Dockerfile, copies over the assembled files and calls the Docker daemon via its remote API. .Example [source,xml] ---- java:8u40 john.doe@example.com latest ${project.version} 8080 /path/to/expose 2147483648 /bin/sh -c groupadd -r appUser useradd -r -g appUser appUser java -jar /opt/demo/server.jar dir /opt/demo assembly.xml ---- In order to see the individual build steps you can switch on `verbose` mode either by setting the property `docker.verbose` or by using `true` in the <> ================================================ FILE: src/main/asciidoc/inc/build/_healthcheck.adoc ================================================ Healthchecks has been introduced since Docker 1.12 and are a way to tell Docker how to test a container to check that it's still working. With a health check you specify a command which is periodically executed and checked for its return value. If the healtcheck return with an exit 0 the container is considered to be healthy, if it returns with 1 then the container is not working correctly. The healtcheck configuration can have the following options .Healthcheck Configuration [cols="1,5"] |=== | Element | Description | *cmd* | Command to execute, which can be given in an shell or exec format as described in <>. | *interval* | Interval for how often to run the healthcheck. The time is specified in seconds, but a time unit can be appended to change this. | *mode* | Mode of the healthcheck. This can be `cmd` which is the default and specifies that the health check should be executed. Or `none` to disable a health check from the base image. Only use this option with `none` for disabling some healthcheck from the base image. | *retries* | How many retries should be performed before the container is to be considered unhealthy. | *startPeriod* | Initialization time for containers that need time to bootstrap. Probe failure during that period will not be counted towards the maximum number of retries. However, if a health check succeeds during the start period, the container is considered started and all consecutive failures will be counted towards the maximum number of retries. Given in seconds, but another time unit can be appended. | *timeout* | Timeout after which healthckeck should be stopped and considered to have failed. Given in seconds, but another time unit can be appended. |=== The following example queries an URL every 10s as an healthcheck: .Example [source,xml] ---- 5m 3s 30m 3 curl -f http://localhost/ || exit 1 ---- ================================================ FILE: src/main/asciidoc/inc/build/_overview.adoc ================================================ [[build-overview]] There are two different modes how images can be built: .Inline plugin configuration With an inline plugin configuration all information required to build the image is contained in the plugin configuration. By default its the standard XML based configuration for the plugin but can be switched to a property based configuration syntax as described in the section <>. The XML configuration syntax is recommended because of its more structured and typed nature. When using this mode, the Dockerfile is created on the fly with all instructions extracted from the configuration given. [[external-dockerfile]] .External Dockerfile or Docker archive Alternatively an external Dockerfile template or Docker archive can be used. This mode is switched on by using one of these three configuration options within * *contextDir* specifies docker build context if an external dockerfile is located outside of Docker build context. If not specified, Dockerfile's parent directory is used as build context. * *dockerFile* specifies a specific Dockerfile path. The Docker build context directory is set to `contextDir` if given. If not the directory by default is the directory in which the Dockerfile is stored. * *dockerArchive* specifies a previously saved image archive to load directly. Such a tar archive can be created with `docker save` or the <<{plugin}:save>> goal. If a `dockerArchive` is provided, no `dockerFile` or `dockerFileDir` must be given. * *dockerFileDir* (_deprecated_, use *contextDir*) specifies a directory containing a Dockerfile that will be used to create the image. The name of the Dockerfile is `Dockerfile` by default but can be also set with the option `dockerFile` (see below). All paths can be either absolute or relative paths (except when both `dockerFileDir` and `dockerFile` are provided in which case `dockerFile` must not be absolute). A relative path is looked up in `${project.basedir}/src/main/docker` by default. You can make it easily an absolute path by using `${project.basedir}` in your configuration. .Adding assemblies in Dockerfile mode Any additional files located in the `dockerFileDir` directory will also be added to the build context as well. You can also use an assembly if specified in an <>. However, you need to add the files on your own in the Dockerfile with an `ADD` or `COPY` command. The files of the assembly are stored in a build context relative directory `maven/` but can be changed by changing the assembly name with the option `` in the assembly configuration. E.g. the files can be added with .Example [source,dockerfile] ---- COPY maven/ /my/target/directory ---- so that the assembly files will end up in `/my/target/directory` within the container. If this directory contains a `.maven-dockerignore` (or alternatively, a `.maven-dockerexclude` file), then it is used for excluding files for the build. Each line in this file is treated as a http://ant.apache.org/manual/Types/fileset.html[FileSet exclude pattern] as used by the http://maven.apache.org/plugins/maven-assembly-plugin[maven-assembly-plugin]. It is similar to `.dockerignore` when using Docker but has a slightly different syntax (hence the different name). <> is an example which excludes all compiled Java classes. [[ex-build-dockerexclude]] .Example `.maven-dockerexclude` or `.maven-dockerignore` ==== [source] ---- target/classes/** # <1> ---- <1> Exclude all compiled classes ==== If this directory contains a `.maven-dockerinclude` file, then it is used for including only those files for the build. Each line in this file is also treated as a http://ant.apache.org/manual/Types/fileset.html[FileSet exclude pattern] as used by the http://maven.apache.org/plugins/maven-assembly-plugin[maven-assembly-plugin]. <> shows how to include only jar file that have build to the Docker build context. [[ex-build-dockerinclude]] .Example `.maven-dockerinclude` ==== [source] ---- target/*.jar # <1> ---- <1> Only add jar file to you Docker build context. ==== Except for the <> all other configuration options are ignored for now. [[simple-dockerfile-build]] .Simple Dockerfile build When only a single image should be built with a Dockerfile no XML configuration is needed at all. All what need to be done is to place a `Dockerfile` into the top-level module directory, alongside to `pom.xml`. You can still configure <> in the plugin configuration, but as soon as you add an `` in the XML configuration, you need to configure also the build explicitly. The image name is by default set from the Maven coordinates (`%g/%a:%l`, see <> for an explanation of the params which are essentially the Maven GAV) This name can be set with the property `docker.name`. If you want to add some `` configuration to this image for starting it with `docker:run` then you can add an image configuration but without a `` section in which case the Dockerfile will be picked up, too. This works only for a single image, though. [[build-filtering]] .Filtering fabric8-maven-plugin filters given Dockerfile with Maven properties, much like the `maven-resource-plugin` does. Filtering is enabled by default and can be switched off with a build config `false`. Properties which we want to replace are specified with the `${..}` syntax. Replacement includes Maven project properties such as `${project.artifactId}`, properties set in the build, command-line properties, and system properties. Unresolved properties remain untouched. This partial replacement means that you can easily mix it with Docker build arguments and environment variable reference, but you need to be careful. If you want to be more explicit about the property delimiter to clearly separate Docker properties and Maven properties you can redefine the delimiter. In general, the `filter` option can be specified the same way as delimiters in the resource plugin. In particular, if this configuration contains a * then the parts left, and right of the asterisks are used as delimiters. For example, the default `${*}` parse Maven properties in the format that we know. If you specify a single character for `` then this delimiter is taken for both, the start and the end. E.g a `@` triggers on parameters in the format `@...@`, much like in the `maven-invoker-plugin`. Use something like this if you want to clearly separate from Docker builds args. This form of property replacement works for Dockerfile only. For replacing other data in other files targeted for the Docker image, please use the `maven-resource-plugin` or an <> with filtering to make them available in the docker build context. .Example The following example uses a Dockerfile in the directory `src/main/docker/demo` and replaces all properties in the format `@property@` within the Dockerfile. [source,xml] ---- user/demo demo @ ... ---- [[build-plugin]] .Build Plugins This plugin supports so call *dmp-plugins* which are used during the build phase. dmp-plugins are enabled by just declaring a dependency in the plugin declaration: [source, xml] ---- io.fabric8 docker-maven-plugin io.fabric8 run-java-sh 1.2.2 ---- These plugins contain a descriptor `META-INF/maven/io.fabric8/dmp-plugin` with class names, line-by-line: [source] ---- io.fabric8.runsh.RunShLoader ---- During a build with `docker:build`, those classes are loaded and certain fixed method are called. The following methods are supported: [[build-plugin-methods]] [cols="1,5"] |=== | Method | Description | *addExtraFiles* | A _static_ method called by dmp with a single `File` argument. This will point to a directory `docker-extra` which can be referenced easily by a Dockerfile or an assembly. A dmp plugin typically will create an own subdirectory to avoid a clash with other dmp-plugins. |=== If a configured plugin does not provide method of this name and signature, then it will be simply ignored. Also, no interface needs to be implemented to keep the coupling low. The following official dmp-plugins are known and supported: [[build-plugins-official]] [cols="1,1,5"] |=== | Name | G,A | Description | https://github.com/fabric8io-images/run-java-sh[run-java.sh] | `fabric8.io`, `run-java` | General purpose startup script fo running Java applications. The dmp plugin creates a `target/docker-extra/run-java/run-java.sh` which can be included in a Dockerfile (see the example above). See the https://github.com/fabric8io-images/run-java-sh[run-java.sh Documentation] for more details. |=== Check out `samples/run-java` for a fully working example. ================================================ FILE: src/main/asciidoc/inc/external/_docker_compose.adoc ================================================ This plugin supports also configuration via a https://docs.docker.com/compose/[docker-compose] file, especially for running containers specified in `docker-compose.yml`. Docker Compose handling is available also as an external configuration provider. .Example [source,xml] ---- webapp fabric8/compose-demo:latest compose src/main/docker docker-compose.yml .... ... ... ---- <1> The alias of the image is used as correlation key mapping to a service in the Docker Compose file <2> An `` configuration handler needs to be used for Docker Compose support <3> The type for the external configuration provider must be set to **compose** <4> Additional configuration for the handler where to find the compose file <5> Extra ``, `` and `` configuration can be provided which are used as default configuration for the Docker compose service `webapp` (as specified with the alias) The following options can be provided: .Docker compose configuration [cols="1,5,1"] |=== | Element | Description | Default | *basedir* | Basedir where to find the compose file and which is also used as the current directory when examing the compose file. Any relative volume bindings will be resolved relative to this directory. | `${basedir}/src/main/docker` | *composeFile* | Name of the compose file to use | `docker-compose.yml` | *ignoreBuild* | Ignore the compose file's `build:` section and use the plugin's build configuration exclusively. | `false` |=== The Docker Compose file can contain variables as described in the https://docs.docker.com/compose/compose-file/#/variable-substitution[Docker Compose documentation]. These are substituted with Maven project properties. Please note, when the `docker-compose.yml` with variables is to be used with the `docker-compose` CLI command, that these variables must also be valid environment variables (i.e. must not contain a `.`). In addition to the `docker-compose.yml` you can add all known options for < >>, < >> and < >> configuration elements which are then used as defaults and are overwritten by the configuration defined in the `docker-compose.yml` file. The merging between the XML configuration and the information found in `docker-compose.yml` is correlated via the `` name. E.g. if the XML image configuration is aliased with `webapp` then its is used as a default configuration for a Docker Compose _service_ name `webapp`. All other services defined in the compose file are left untouched. === Limitations The following Docker Compose file keywords are not yet supported: * `cgroup_parent`, `devices`, `env_file`, `expose`, `pid`, `security_opt`, `stop_signal`, `cpu_quota`, `ipc`, `mac_address`, `read_only` are not yet supported (but might be in a future version). * `extend` for including other Docker Compose files is not yet implemented. * Only **services** are currently evaluated, there is no supported yet for **volumes** and **networks**. ================================================ FILE: src/main/asciidoc/inc/external/_property_configuration.adoc ================================================ For simple needs the image configuration can be completely defined via Maven properties which are defined outside of this plugin's configuration. Such a property based configuration can be selected with an `` of `properties`. As extra configuration a prefix for the properties can be defined which by default is `docker`. For single-image configurations it is also possible to active property based configuration via an externally set property. By default, property based configuration uses only properties, ignoring any `` and `` sections. To combine values from both sources, use the <>. Properties are read from the Maven project (defined in `` or global Maven configuration from `settings.xml`) and, since 0.25.0, from any `-D` flags given to Maven (takes priority over project properties). .Example [source,xml] ---- properties docker only ---- Given this example configuration a single image configuration is built up from the following properties, which correspond to the corresponding values in the `` and `` sections. A build configuration is only created when a `docker.from` or a `docker.fromExt` is set. .External properties [cols="1,5"] |=== | *docker.alias* | Alias name | *docker.args.BUILDVAR* | Set the value of a build variable. The syntax is the same as for specifying environment variables (see below). | *docker.assembly.baseDir* | Directory name for the exported artifacts as described in an assembly (which is `/maven` by default). | *docker.assembly.descriptor* | Path to the assembly descriptor when building an image | *docker.assembly.descriptorRef* | Name of a predefined assembly to use. | *docker.assembly.exportBaseDir* | If `true` export base directory | *docker.assembly.ignorePermissions* | If set to `true` existing file permissions are ignored when creating the assembly archive. Deprecated, use a permission mode of `ignore` instead. | *docker.assembly.permissions* | can be `ignore` to use the permission as found on files regardless on any assembly configuration, `keep` to respect the assembly provided permissions, `exec` for setting the executable bit on all files (required for Windows when using an assembly mode `dir`) or `auto` to let the plugin select `exec` on Windows and `keep` on others. `keep` is the default value. | *docker.assembly.dockerFileDir* | specifies a directory containing an external Dockerfile that will be used to create the image. This is deprecated please use `docker.dockerFileDir` or `docker.dockerFile` instead. | *docker.noCache* | Don't use Docker's build cache. This can be overwritten by setting a system property `docker.noCache` when running Maven. | *docker.bind.idx* | Sets a list of paths to bind/expose in the container | *docker.buildArg.VARIABLE* | Set a ARG to be available during build of image. *Note*: this is handled separately from external configuration, and is always available. See <> for more details. | *docker.capAdd.idx* | List of kernel capabilities to add to the container | *docker.capDrop.idx* | List of kernel capabilities to remove from the container | *docker.cleanup* | Cleanup dangling (untagged) images after each build (including any containers created from them). Default is `try` (which wont fail the build if removing fails), other possible values are `none` (no cleanup) or `remove` (remove but fail if unsuccessful) | *docker.cmd* | Command to execute. This is used both when running a container and as default command when creating an image. | *docker.cpus* | Specify how much of the available CPU resources a container can use | *docker.cpuset* | Limit the container to specific CPUs or cores. This can be provided either as a comma-separated list or a hyphen-separated range. | *docker.cpushares* | Set the proportion of the host machine's cpu cycles available to the container | *docker.cacheFrom* | List of image names to use as cache sources | *docker.domainname* | Container domain name | *docker.dns.idx* | List of dns servers to use | *docker.dnsSearch.idx* | List of dns search domains | *docker.dockerArchive* | specify an archive which can be loaded with `docker load`. Use this as an alternative to `docker.dockerFile` or `docker.dockerFileDir` | *docker.dockerFile* | specifies a Dockerfile to use. This property must point to the Dockerfile itself. | *docker.dockerFileDir* | specifies a directory containing an external dockerfile that will be used to create the image. The dockerfile must be name `Dockerfile` | *docker.entrypoint* | Container entry point | *docker.exposedPropertyKey* | Property part for the exposed container properties like internal IP addresses as described in <>. | *docker.env.VARIABLE* | Sets an environment variable used in build and run. E.g. `-Xmx512m` sets the environment variable `JAVA_OPTS`. Multiple such entries can be provided. This environment is used both for building images and running containers. The value cannot be empty but can contain Maven property names which are resolved before the Dockerfile is created. | *docker.envBuild.VARIABLE* | Sets an environment variable used in build only. E.g. `-Xmx512m` sets the environment variable `JAVA_OPTS`. Multiple such entries can be provided. This environment is building images only. The value cannot be empty but can contain Maven property names which are resolved before the Dockerfile is created. | *docker.envRun.VARIABLE* | Sets an environment variable used in run only. E.g. `-Xmx512m` sets the environment variable `JAVA_OPTS`. Multiple such entries can be provided. This environment is used both for running containers only. The value cannot be empty but can contain Maven property names which are resolved before the Dockerfile is created. | *docker.envPropertyFile* | specifies the path to a property file whose properties are used as environment variables in run. The environment variables takes precedence over any other environment variables specified. | *docker.extraHosts.idx* | List of `host:ip` to add to `/etc/hosts` | *docker.filter* | Enable and set the delimiters for property replacements. By default properties in the format `${..}` are replaced with Maven properties. You can switch off property replacement by setting this property to `false`. When using a single char like `@` then this is used as a delimiter (e.g `@...@`). See <> for more details. | *docker.from* | Base image for building an image. Must be set when an image is created (or `fromExt`) | *docker.fromExt.VARIABLE* | Base image for building an image (extended format), which also triggers a build of an image. | *docker.healthcheck.cmd* | Command to use for a healthcheck | *docker.healthcheck.interval* | Interval for how often to run a healthcheck (in seconds or with a given time unit) | *docker.healthcheck.mode* | If se to `none` disable a healthcheck from a base image | *docker.healthcheck.retries* | Number of retries for how often to retry a healthcheck until it is considered to have failed | *docker.healthcheck.startPeriod* | Initialization time for containers that need time to bootstrap. Probe failure during that period will not be counted towards the maximum number of retries. However, if a health check succeeds during the start period, the container is considered started and all consecutive failures will be counted towards the maximum number of retries. (in seconds or with a given time unit) | *docker.healthcheck.timeout* | Timeout after which a healthcheck command is considered to be failed (in seconds or with a given time unit) | *docker.hostname* | Container hostname | *docker.imagePropertyConfiguration* | Special property to activate property configuration without altering XML file (see <>). | *docker.imagePullPolicy.build* | Specific pull policy used when building images. See <> for the possible values. | *docker.imagePullPolicy.run* | Specific pull policy used for downloading images to run. See <> for the possible values. | *docker.labels.LABEL* | Sets a label which works similarly like setting environment variables. | *docker.loadNamePattern* | Search the archive specified in `docker.dockerArchive` for the specified image name and creates a tag from the matched name to the build image name specified in `docker.name`. | *docker.log.enabled* | Use logging (default: `true`) | *docker.log.prefix* | Output prefix | *docker.log.color* | ANSI color to use for the prefix | *docker.log.date* | Date format for printing the timestamp | *docker.log.driver.name* | Name of an alternative log driver | *docker.log.driver.opts.VARIABLE* | Logging driver options (specified similarly as in `docker.env.VARIABLE`) | *docker.links.idx* | defines a list of links to other containers when starting a container. _idx_ can be any suffix which is not used except when _idx_ is numeric it specifies the order within the list (i.e. the list contains first entries with numeric indexes sorted and the all non-numeric indexes in arbitrary order). For example `db` specifies a link to the image with alias 'db'. | *docker.maintainer* | defines the maintainer's email as used when building an image | *docker.memory* | Container memory (in bytes) | *docker.memorySwap* | Total memory (swap + memory) `-1` to disable swap | *docker.name* | Image name | *docker.namingStrategy* | Container naming (either `none` or `alias`) | *docker.network.mode* | Network mode to use which can be `none`, `host`, `bridged`, `container` or `custom` | *docker.network.name* | Name of the custom network when mode is `custom`, or for mode `container` the image alias name used to create the container. | *docker.network.alias.idx* | One or more aliase for a custom network. Only used when the network mode is `custom` | *docker.noCache* | Don't use a cache when building the image | *docker.squash* | Squash newly built layers into a single layer (API 1.25+, need to be enabled in the Docker daemon configuration) | *docker.optimise* | if set to true then it will compress all the `runCmds` into a single RUN directive so that only one image layer is created. | *docker.portPropertyFile* | specifies a path to a port mapping used when starting a container. | *docker.ports.idx* | Sets a port mapping. For example `jolokia.ports:8080` maps the container port 8080 dynamically to a host port and assigns this host port to the Maven property `${jolokia.port}`. See <<_port-mapping,Port mapping>> for possible mapping options. When creating images images only the right most port is used for exposing the port. For providing multiple port mappings, the index should be count up. | *docker.registry* | Registry to use for pushing images. | *docker.restartPolicy.name* | Container restart policy | *docker.restartPolicy.retry* | Max restart retries if `on-failure` used | *docker.run.idx* | List of commands to `RUN` when creating the image | *docker.securityOpts.idx* | List of `opt` elements to specify kernel security options to add to the container. For example `docker.securityOpt.1=seccomp=unconfined` | *docker.shmsize* | Size of `/dev/shm` in bytes. | *docker.tags.idx* | List of tags to apply to a built image | *docker.tmpfs.idx* | One or more mount points for a *tmpfs*. Add mount options after a `:` | *docker.ulimits.idx* | Ulimits for the container. Ulimit is specified with a soft and hard limit `=[:]`. For example `docker.ulimits.1=memlock=-1:-1` | *docker.user* | User to switch to at the end of a Dockerfile. Not to confuse with `docker.username` which is used for authentication when interacting with a Docker registry. | *docker.volumes.idx* | defines a list of volumes to expose when building an image | *docker.volumesFrom.idx* | defines a list of image aliases from which the volumes should be mounted of the container. The list semantics is the same as for links (see above). For examples `data` will mount all volumes exported by the `data` image. | *docker.wait.http.url* | URL to wait for during startup of a container | *docker.wait.http.method* | HTTP method to use for ping check | *docker.wait.http.status* | Status code to wait for when doing HTTP ping check | *docker.wait.time* | Amount of time to wait during startup of a container (in ms) | *docker.wait.log* | Wait for a log output to appear. | *docker.wait.exec.postStart* | Command to execute after the container has start up. | *docker.wait.exec.preStop* | Command to execute before command stops. | *docker.wait.exec.breakOnError* | If set to "true" then stop the build if the a `postStart` or `preStop` command failed | *docker.wait.shutdown* | Time in milliseconds to wait between stopping a container and removing it. | *docker.wait.tcp.mode* | Either `mapped` or `direct` when waiting on TCP connections | *docker.wait.tcp.host* | Hostname to use for a TCP wait checks | *docker.wait.tcp.port.idx* | List of ports to use for a TCP check. | *docker.wait.kill* | Time in milliseconds to wait between sending SIGTERM and SIGKILL to a container when stopping it. | *docker.workdir* | Container working directory where the image is build in | *docker.workingDir* | Current Working dir for commands to run in when running containers |=== Multiple property configuration handlers can be used if they use different prefixes. As stated above the environment and ports configuration are both used for running container and building images. If you need a separate configuration you should use explicit run and build configuration sections. [[combining-property-config]] .Combining property and XML configuration By default the property handler will only consider properties and ignore any other image configuration in the XML/POM file. This can be changed by adding the `` configuration (since version 0.25.0), which can have one of the following values: .Property mode [cols="1,5"] |=== |`only` | Only look at properties, ignore any `` or `` sections for this image. This is the default, and also the behavior in versions before 0.25.0. |`override` | Use property if set, else fall back to value found in `` or `` sections for this image. |`fallback` | Use value found in `` or `` sections for this image, else fall back to to property value. |`skip` | Effectively disable properties, same as not specifying the `` section at all. |=== [[combining-property-config-externally]] .Activating property configuration externally It also possible to activate property configuration by setting the property `docker.imagePropertyConfiguration` to a valid `property mode`, without adding an `` section. The plugin will then use any properties with default `docker.` prefix. This can be useful if most of the configuration is specified in XML/POM file, but there is need to override certain configuration values without altering the POM file (instead add this to a parent POM or global settings.xml). If set in parent POM, but not wanted in specific project, the property could be overriden locally with the value `skip` to disabled property configuration for that particular project. If set in settings.xml however, by Maven design, that value will always take precedence over any properties defined in pom.xml. For configurations with multiple images, using this property will by default produce an error. All images would then use the same `docker` property prefix, resulting in multiple identical configurations. This can be overruled by adding an explicit configuration element with an explicit to all images (or at least all but one). Normally you'd want to use different prefix for each image, but if explicitly set it does allow you to use the same prefix (even `docker`) on all images. This is useful in case you just want to share a few properties. This only makes sense when `property mode` is _override_ or _fallback_ and image-specific configuration are defined in the POM configuration. For examples, see <> .Merging POM and property values For some fields it may be desired to merge values from both POM and properties. For example, in a certain run environment we might want to inject a `http_proxy` environment variable, but we do not want to add this to the POM file. This is solved using a *Combine policy* which can be either `replace` or `merge`. Merge is only available for configuration of Map or List type. For scalar values such as strings and integers, it is not supported. For Maps, both sources are merged, with the priority source taking precedence. For Lists, they are concatenated, with values from the priority source being added first. Combine policy is specified per configuration key/property, and the default in most cases is currently `replace`. The following keys have `merge` as default policy: * docker.args * docker.envBuild * docker.envRun * docker.labels * docker.ports * docker.tags This can be overridden individually for all configuration keys (of map/list type) by setting an additional property suffixed `._combine`. For example, to not merge ports, set `docker.ports._combine=replace`, and to enable merging of dns, set `docker.dns._combine=merge`. .Example, properties only [source,xml] ---- jolokia/demo service consol/tomcat:7.0 src/main/docker-assembly.xml -Xmx32m ${project.version} 8080 http://localhost:${jolokia.port}/jolokia io.fabric8 docker-maven-plugin properties docker ---- [[externally-property-config-example]] .Example, combining properties and XML/POM configuration [source,xml] ---- src/main/docker-assembly.xml -Xmx32m ${project.version} 8080 http://localhost:${jolokia.port}/jolokia io.fabric8 docker-maven-plugin properties docker override jolokia/demo service consol/tomcat:7.0 tomcat ---- This would build the same image as the previous example. If instead built with `mvn docker:build -Pdocker.from=console/tomcat:8.0 -Ddocker.tags.0=tc8-test` it would build from that image instead, and also add that tag to the image. If `-Ddocker.labels.status=beta` is added, the image would be given two labels: `status=beta` and `software=tomcat`. If `-Ddocker.labels._combine=replace` is added, the image would be given one label only: `status=beta`. .Example, external activation of property configuration, single image Global ~/.m2/settings.xml file: [source,xml] ---- http-proxy http://proxy.example.com:8080 http://proxy.example.com:8080 override ---- [source,xml] ---- io.fabric8 docker-maven-plugin jolokia/demo service consol/tomcat:7.0 ---- When the plugin is executed, on a machine with the given settings.xml, the plugin will see the `docker.imagePropertyConfiguration` configuration and enable the property merging feature. When building, it will inject the http_proxy build ARG, and when running, it will inject the http_proxy ENV variable. The rest of the configuration will be sourced from the XML, unless the Maven project has any other `docker.*` properties defined. .Example, external activation of property configuration, two images Using the same global ~/.m2/settings.xml file as in previous example, but with two image definitions and no extra configuration will cause an error, saying that you cannot use property docker.imagePropertyConfiguration on projects with multiple images. By adding an explicit external configuration directive with the same prefix in both images, this error is disabled. [source,xml] ---- io.fabric8 docker-maven-plugin properties docker override jolokia/demo service consol/tomcat:7.0 properties docker override jolokia/demo2 service2 consol/tomcat:7.0 ---- The behaviour will now be same as previous example. Note that you must explicitly state `override`, otherwise it will use the default `only`. ================================================ FILE: src/main/asciidoc/inc/image/_configuration.adoc ================================================ [[config-image]] .Image Configuration [cols="1,5"] |=== | Element | Description | *name* | Each `` configuration has a mandatory, unique docker repository _name_. This can include registry and tag parts, but also placeholder parameters. See below for a detailed explanation. | *alias* | Shortcut name for an image which can be used for identifying the image within this configuration. This is used when linking images together or for specifying it with the global *image* configuration element. | <> | Registry to use for this image. If the `name` already contains a registry this takes precedence. See <> for more details. | <> | Element which contains all the configuration aspects when doing a <<{plugin}:build>>. This element can be omitted if the image is only pulled from a registry e.g. as support for integration tests like database images. ifeval::["{plugin}" == "docker"] | <> | Element which describe how containers should be created and run when <<{plugin}:start>> is called. If this image is only used a _data container_ (i.e. is supposed only to be mounted as a volume) for exporting artifacts via volumes this section can be missing. | <> | Specification of external configuration as an alternative to this XML based configuration with `` and ``. It contains a `` element specifying the handler for getting the configuration. See <> for details. endif::[] | *removeNamePattern* | When this image is to be removed by <<{plugin}:remove>>, use this <> to find images to remove rather than just using the name. | *stopNamePattern* | When containers associated with this image will be stopped by <<{plugin}:stop>>, use this <> to find containers to remove rather than just using the associated container name. |=== ================================================ FILE: src/main/asciidoc/inc/image/_example.adoc ================================================ .Example [source,xml] ---- .... %g/docker-demo:0.1 service .... .... ---- ================================================ FILE: src/main/asciidoc/inc/image/_example_imagesMap.adoc ================================================ .Example [source,xml] ---- .... %g/docker-demo:0.1 .... .... ---- ================================================ FILE: src/main/asciidoc/inc/image/_naming.adoc ================================================ [[image-name]] ## Image Names When specifying the image name in the configuration with the `` field you can use several placeholders which are replaced during runtime by this plugin. In addition you can use regular Maven properties which are resolved by Maven itself. [cols="1,5"] |=== | Placeholder | Description | *%g* | The last part of the Maven group name, sanitized so that it can be used as username on GitHub. Only the part after the last dot is used. E.g. for a group id `io.fabric8` this placeholder would insert `fabric8` | *%a* | A sanitized version of the artefact id so that it can be used as part of an Docker image name. I.e. it is converted to all lower case (as required by Docker) | *%v* | The project version. Synonym to `${project.version}` | *%l* | If the project version ends with `-SNAPSHOT` then this placeholder is `latest`, otherwise its the full version (same as `%v`) | *%t* | If the project version ends with `-SNAPSHOT` this placeholder resolves to `snapshot-` where timestamp has the date format `yyMMdd-HHmmss-SSSS` (eg `snapshot-`). This feature is especially useful during development in oder to avoid conflicts when images are to be updated which are still in use. You need to take care yourself of cleaning up old images afterwards, though. |=== ifeval::["{plugin}" == "docker"] [[container-name]] ## Container Names Similar to image name placeholders, for starting and stopping containers and alternate set of placeholders can be configured in order to the name the containers to create. These placeholders can be used in the top-level configuration value `containerNamePattern` which is used globally for every container that is created. This global pattern can be overwritten individually by each image's <> configuration. If neither is given, then by default the pattern `%n-%i` is used. When specifying the container name pattern the following placeholders can be used: [cols="1,5"] |=== | Placeholder | Description | *%a* | The `` of an image which must be set. The alias is set in the top-level image configuration | *%n* | A sanitized version of the imag's short name from which this container is created. "Sanitized" means that any non letter, digit, dot or dash is replaced by an underscore. | *%t* | The build time stamp. This is the timestamp which created during the building of an image and locally cached. A rebuild of the image will update the timestamp. | *%i* | An index which is incremented if a container has already been created. With this parameter it is easily possible to have multiple, similar containers. See the example below for more details. |=== You can combine the placeholders in any combination and will be resolved during `docker:start`, `docker:stop` and `docker:watch`. The following example is using a container name pattern of `%n-%i` which is also the default. Given an image `fabric8io/dmp-sample-jolokia:latest`, then during `mvn docker:start` a container with the name `dmp-sample-jolokia-1` is first tried. If there is already a container with this name, then `dmp-sample-jolokia-2` is the second attempt. This goes on until a "free" name is found. Similar, when stopping containers with `mvn docker:stop` then only the container with the highest index is stopped. However, if you don't use an index via `%i` then _all_ containers started with `docker:start` are stopped. Use `mvn docker:stop -Ddocker.allContainers` to also stop every container named via a `%i` pattern. endif::[] [[name-patterns]] ## Name Patterns Goals that need to refer to images or containers where the name of the image or container is not fixed may support name patterns for matching. Patterns can use an Ant-like syntax or Java regular expressions. ### Ant-like Name Patterns Ant path matching patterns that operate on path names use the convention that a `$$*$$` matches within a single path component, while `$$**$$` can match multiple components. Adapting this style to image names requires some tweaks since image names may include registry information, a path-like repository name and a tag. Consider the following image names: * `alpine:latest` * `fluent/fluentd:edge` * `quay.io/operator-framework/helm-operator:v0.9.0` * `company.local:5000/division/project/artifact:version` Unlike in Ant matching of file system paths, the `:` is an important marker, but only at the end where it separates the version from the repository. Also, patterns that match repository names need to anticipate that there may be a registry name at the beginning if the image has been tagged for pushing to a registry. Taking this into account, the name pattern wildcards are: * `?` matches a single character * `*` matches zero or more characters, up to the next slash or the tag separator * `**` matches zero or more characters, up to the tag separator * `**/` matches zero or more characters, up to the tag separator, and ensures that if any characters are matched, the final character matched is a slash #### Examples of Ant-like Name Patterns [cols="1,3,3"] |=== | Pattern | Matches | Does Not Match | `$$**tomcat:jdk-11*$$` a| * megacorp/tomcat:jdk-11-alpine * megacorp.com:5000/megacorp/project-x-tomcat:jdk-11 a| * megacorp/tomcat__-operator__:jdk-11 * megacorp/project-x-tomcat:__jdk-9-alpine__ | `$$**/megacorp/tomcat:*alpine$$` a| * megacorp/tomcat:alpine * megacorp.com:5000/megacorp/tomcat:jdk-11-alpine a| * megacorp/tomcat:__jdk-11__ * megacorp.com:5000/__ultra__megacorp/tomcat:jdk-11-alpine | `$$megacorp/*-operator:*$$` a| * megacorp/tomcat-operator:alpine * megacorp/mysql-operator:latest a| * megacorp/__tomcat__:jdk-11 * __megacorp.com:5000/__megacorp/tomcat-operator:alpine |=== ### Java Regular Expression Patterns To indicate that a name pattern is a Java regular expression, prefix the regular expression with `$$%regex[$$` and suffix with `$$]$$`. #### Examples of Java Regular Expression Patterns [cols="1,3,3"] |=== | Pattern | Matches | Does Not Match | `$$%regex[j(dk\|re)-11]$$` a| * megacorp/tomcat:jdk-11-alpine * openjdk-11:latest a| * openjdk:11-alpine | `$$%regex[tomcat]$$` a| * megacorp/tomcat:alpine * megacorp.com:5000/tomcat-projects/project-x:latest a| * megacorp/topcat:edge |=== [[name-pattern-lists]] ### Name Pattern Lists In goals such as <<{plugin}:stop>> and <<{plugin}:remove>> where multiple patterns are supported, separate patterns with commas. ================================================ FILE: src/main/asciidoc/inc/misc/_env.adoc ================================================ When creating a container one or more environment variables can be set via configuration with the `env` parameter .Example [source,xml] ---- /opt/jdk8 -Djava.security.egd=file:/dev/./urandom ---- If you put this configuration into profiles you can easily create various test variants with a single image (e.g. by switching the JDK or whatever). It is also possible to set the environment variables from the outside of the plugin's configuration with the parameter `envPropertyFile`. If given, this property file is used to set the environment variables where the keys and values specify the environment variable. Environment variables specified in this file override any environment variables specified in the configuration. Labels can be set inline the same way as environment variables: .Example [source,xml] ---- foo ${project.version} ${project.artifactId} ---- ================================================ FILE: src/main/asciidoc/inc/misc/_startup.adoc ================================================ Using `entrypoint` and `cmd` it is possible to specify the https://docs.docker.com/reference/builder/#entrypoint[entry point] or https://docs.docker.com/reference/builder/#cmd[cmd] for a container. The difference is, that an `entrypoint` is the command that always be executed, with the `cmd` as argument. If no `entrypoint` is provided, it defaults to `/bin/sh -c` so any `cmd` given is executed with a shell. The arguments given to `docker run` are always given as arguments to the `entrypoint`, overriding any given `cmd` option. On the other hand if no extra arguments are given to `docker run` the default `cmd` is used as argument to `entrypoint`. **** See this http://stackoverflow.com/questions/21553353/what-is-the-difference-between-cmd-and-entrypoint-in-a-dockerfile[stackoverflow question] for a detailed explanation. **** An entry point or command can be specified in two alternative formats: .Entrypoint and Command Configuration [cols="1,5"] |=== | Mode | Description | *shell* | Shell form in which the whole line is given to `shell -c` for interpretation. | *exec* | List of arguments (with inner ``) arguments which will be given to the `exec` call directly without any shell interpretation. |=== Either shell or params should be specified. .Example [source,xml] ---- java -jar $HOME/server.jar ---- or .Example [source,xml] ---- java -jar /opt/demo/server.jar ---- This can be formulated also more dense with: .Example [source,xml] ---- java -jar $HOME/server.jar ---- or .Example [source,xml] ---- java -jar /opt/demo/server.jar ---- ================================================ FILE: src/main/asciidoc/inc/push/_configuration.adoc ================================================ .Push options [cols="1,5,1"] |=== | Element | Description | Property | *skipPush* | If set to `true` the plugin won't push any images that have been built. | `docker.skip.push` | *skipTag* | If set to `true` this plugin won't push any tags | `docker.skip.tag` | *pushRegistry* | The registry to use when pushing the image. See <> for more details. | `docker.push.registry` | *retries* | How often should a push be retried before giving up. This useful for flaky registries which tend to return 500 error codes from time to time. The default is 0 which means no retry at all. | `docker.push.retries` |=== ================================================ FILE: src/main/asciidoc/inc/push/_overview.adoc ================================================ This goal uploads images to the registry which have a `` configuration section. The images to push can be restricted with the global option `filter` (see <> for details). The registry to push is by default `docker.io` but can be specified as part of the images's `name` name the Docker way. E.g. `docker.test.org:5000/data:1.5` will push the image `data` with tag `1.5` to the registry `docker.test.org` at port `5000`. Security information (i.e. user and password) can be specified in multiple ways as described in section <>. By default a progress meter is printed out on the console, which is omitted when using Maven in batch mode (option `-B`). A very simplified progress meter is provided when using no color output (i.e. with `-Ddocker.useColor=false`). ================================================ FILE: src/main/asciidoc/inc/start/_configuration.adoc ================================================ In addition to the <>, this goal supports the following global configuration options. .Start options [cols="1,5,1"] |=== | Element | Description | Property | <> | Default pattern for naming all containers when they are created. See <> for details. | `docker.containerNamePattern` | *showLogs* | In order to switch on globally the logs *showLogs* can be used as global configuration (i.e. outside of ``). If set it will print out all standard output and standard error messages for all containers started. As value the images for which logs should be shown can be given as a comma separated list. This is probably most useful when used from the command line as system property `docker.showLogs`. | `docker.showLogs` | *startParallel* | Starts docker images in parallel while dependencies expressed as <> or <> are respected. This option can significantly reduce the startup time because independent containers do not need to wait for each other. | `docker.startParallel` |=== The `` configuration element knows the following sub elements: [[config-image-run]] .Run configuration (< >>) [cols="1,5"] |=== | Element | Description | *capAdd* | List of `add` elements to specify kernel parameters to add to the container. | *capDrop* | List of `drop` elements to specify kernel parameters to remove from the container. | <> | Command which should be executed at the end of the container's startup. If not given, the image's default command is used. See <> for details. | <> | Pattern for naming the container when it is created. See <> for details. | *domainname* | Domain name for the container | *dns* | List of `host` elements specifying dns servers for the container to use | *dnsSearch* | List of `host` elements specifying dns search domains | *entrypoint* | Entry point for the container. See <> for details. | <> | Environment variables as subelements which are set during startup of the container. They are specified in the typical maven property format as described <>. | *envPropertyFile* | Path to a property file holding environment variables. If given, the variables specified in this property file overrides the environment variables specified in the configuration. | *extraHosts* | List of `host` elements in the form `host:ip` to add to the container's `/etc/hosts` file. Additionally, you may specify a `host` element in the form `host:host` to have the right side host ip address resolved at container startup. | *exposedPropertyKey* | Set the property part for the exposed container properties as described <>. This will take precedence of the image's `alias` which is the default value. For example, when this property is set to `jboss`, then for this container its IP address is exposed in Maven property `docker.container.jboss.ip` regardless how the image is named. | *hostname* | Hostname of the container | *imagePullPolicy* | Specific pull policy for downloading the image. This overwrites any global pull policy. See the global <> configuration option for the possible values and the default. | <> | Labels which should be attached to the container. They are specified in the typical maven property format as described in <>. | <> | Network links for connecting containers together as described in <>. | <> | Log configuration for whether and how log messages from the running containers should be printed. This also can configure the https://docs.docker.com/engine/admin/logging/overview[log driver] to use. See <> for a detailed description. | *memory* | Memory limit in bytes | *memorySwap* | Total memory usage (memory + swap); use -1 to disable swap. | *namingStrategy* a| *This option is deprecated, please use a `containerNamePattern` instead* Naming strategy for how the container name is created: * *none* : uses randomly assigned names from docker (default) * *alias* : uses the `alias` specified in the `image` configuration. An error is thrown, if a container already exists with this name. | <> | Network configuration for your container. | <> | File path into which the mapped port properties are written. The format of this file and its purpose are also described in <> | <> | <> for exposing container ports to host ports. | *privileged* | If `true` give container full access to host | *readOnly* | If `true` mount the container's root filesystem as read only | *autoRemove* | If `true` automatically remove the container when it exits. This has no effect if <> has been set. | <> | Restart Policy | *securityOpts* | List of `` elements to specify kernel security options to add to the container. See below for an example. | *shmSize* | Size of `/dev/shm` in bytes. | *skip* | If `true` disable creating and starting of the container. This option is best used together with a Maven property which can be set from the outside. | *stopMode* | Specifies how to stop a running container. It supports the modes `graceful` and `kill` as values, with `graceful` being the default. | *tmpfs* a| List countaintin `` elements for directories to mount with a temporary filesystem. Optionally, mount options can be appended after a ':'. See below for an example. | *ulimits* a| ulimits for the container. This list contains `` elements which three sub elements: * `` : The ulimit to set (e.g. `memlock`). Please refer to the Docker documentation for the possible values to set * `` : The hard limit * `` : The soft limit See below for an example. | *user* | User used inside the container | <> | Volume configuration for binding to host directories and from other containers. See Volumes for details. | <> | Condition which must be fulfilled for the startup to complete. See <> for all possible ways to wait for a startup condition. | *workingDir* | Working directory for commands to run in |=== .Example [source,xml] ---- -Xmx32m development ${project.version} jolokia.port:8080 memlock -1 -1 /var/lib/mysql:size=10m /opt/mydata seccomp=unconfined db http://localhost:${jolokia.port}/jolokia DEMO ISO8601 blue java -jar /maven/docker-demo.jar ---- ================================================ FILE: src/main/asciidoc/inc/start/_depends-on.adoc ================================================ Custom networks do not provide a mechanism like `` to express strong links between containers. They are normally not required because docker ensures that all containers within the same custom network can eventually resolve each other via DNS. Your containers should preferably be able to deal with temporarily unresolvable dependencies but in some cases it is helpful to be able to rely the availability of other infrastructure containers. The `` configuration can be used to expresses custom network dependencies between your containers. `docker:start` will ensure that all dependencies a container depends on are completely started (fulfilling all `` conditions) before the depending container is started. Additionally, each `` element can specify a comma separated set of containers. Comma (and whitespace) can be used to separate containers since valid docker container names contain only characters, digits, underscores, periods and dashes. .Example [source,xml] ---- postgres logstash ---- ================================================ FILE: src/main/asciidoc/inc/start/_links.adoc ================================================ The `` configuration contains a list of containers that should be linked to this container according to https://docs.docker.com/userguide/dockerlinks[Docker Links]. Each link can have two parts where the optional right side is separated by a `:` and will be used as the name in the environment variables and the left side refers to the name of the container linking to. This is equivalent to the linking when using the Docker CLI `--link` option. Example for linking to a container with name or alias _postgres_ : .Example [source,xml] ---- postgres:db ---- This will create the following environment variables, given that the postgres image exposes TCP port 5432: .Example [source,bash] ---- DB_NAME=/web2/db DB_PORT=tcp://172.17.0.5:5432 DB_PORT_5432_TCP=tcp://172.17.0.5:5432 DB_PORT_5432_TCP_PROTO=tcp DB_PORT_5432_TCP_PORT=5432 DB_PORT_5432_TCP_ADDR=172.17.0.5 ---- Additionally, each `` element can specify a comma separated set of links. Comma (and whitespace) can be used to separate links since valid docker link names/aliases contain only characters, digits, underscores, periods and dashes. .Example [source,xml] ---- postgres:db, search, saml:identity ---- If you wish to link to existing containers not managed by the plugin, you may do so by specifying the container name obtained via `docker ps` in the configuration. Please note that the link behaviour also depends on the network mode selected. Links as described are referred to by Docker as _legacy links_ and might vanish in the future. For custom networks no environments variables are set and links create merely network aliases for the linked container. To express start order dependencies using custom networks refer to the <> configuration. For a more detailed documentation for the new link handling please refer to the https://docs.docker.com/engine/userguide/networking/work-with-networks/#linking-containers-in-user-defined-networks[Docker network documentation] ================================================ FILE: src/main/asciidoc/inc/start/_logging.adoc ================================================ When running containers the standard output and standard error of the container can be printed out. Several options are available for configuring the log output: .Logging configuration [cols="1,5"] |=== | Element | Description | *enabled* | If set to `false` log output is disabled. This is useful if you want to disable log output by default but want to use the other configuration options when log output is switched on on the command line with `-Ddocker.showLogs`. Logging is enabled by default if a `` section is given. | *prefix* a| Prefix to use for the log output in order to identify the container. You can use placeholders in the prefix which are replaced on the fly: * `%a`: Alias of the image, or, if not set, the short container id. * `%c`: Short container id (i.e. the first 6 chars of the container id * `%C`: The full container id * `%n`: The image name * `%z`: An empty string By default the format is "%a> ". | *date* a| Dateformat to use for log timestamps. If `` is not given no timestamp will be shown. The date specification can be either a constant or a date format. The recognized constants are: * `NONE` Switch off timestamp output. Useful on the command line (`-Ddocker.logDate=NONE`) for switching off otherwise enabled logging. * `DEFAULT` A default format in the form `HH:mm:ss.SSS` * `MEDIUM` java.time medium date time format * `SHORT` java.time short date time format * `LONG` java.time long date time format * `ISO8601` Full ISO-8601 formatted date time with milliseconds As an alternative a date-time format string as recognized by https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html[java.time] is possible. In order to set a consistent date format, the global configuration parameter `logDate` can be used. | *color* | Color used for coloring the prefix when coloring is enabled (i.e. if running in a console and `useColor` is set). The available colors are `YELLOW`, `CYAN`, `MAGENTA`, `GREEN`, `RED`, `BLUE`. If coloring is enabled and now color is provided a color is picked for you. | *file* | Path to a file to which the log output is written. This file is overwritten for every run and colors are switched off. | *driver* | Section which can specify a dedicated log driver to use. A `` tag within this section depicts the logging driver with the options specified in ``. See the example below for how to use this. |=== .Example [source,xml] ---- TC default cyan ---- The following example switches on the `gelf` https://docs.docker.com/engine/admin/logging/overview[logging driver] . This is equivalent to the options `--log-driver=gelf --log-opt gelf-address=udp://localhost:12201` when using `docker run`. [source,xml] ---- ... gelf udp://localhost:12201 ---- ================================================ FILE: src/main/asciidoc/inc/start/_network.adoc ================================================ The `` element in the < >> configuration section can be used to configure the network mode of the container. This is now the preferred way for linking containers together. It knows the following sub elements: .Network configuration [cols="1,7"] |=== | Element | Description | *mode* a| The network mode, which can be one of the following values: * *bridge* : Bridged mode with the default Docker bridge (default) * *host* : Share the Docker host network interfaces * *container* : Connect to the network of the specified container. The name of the container is taken from the `` element. * *custom* : Use a custom network, which must be created before by using `docker network create`. Alternatively you can set the ```docker.autoCreateCustomNetworks``` <> parameter to ```true``` to automatically create custom networks. Custom networks are available for Docker 1.9 and newer. For more about the networking options please refer to the https://docs.docker.com/engine/userguide/networking/work-with-networks[Docker documentation]. * *none* : No network will be setup. | *name* | For mode `container` this is the container name, which is this image alias. For Mode `custom` this is the name of the custom network. | *alias* | One or more alias element can be provided which gives a way for a container to be discovered by alternate names by any other container within the scope of a particular network. This configuration only has effect for when the network mode is `custom`. More than one alias can be given by providing multiple entries. |=== If no `mode` is given but a `name`, then a `custom` network mode is assumed. For the simple modes which does not take an argument (`none`, `bridge` or `host`) a single `` _mode_ `` can be used as alternative to using `` with a `` subelement. .Example [source,xml] ---- custom my-network box1 box2 ---- or for a simple `host` network: .Example [source, xml] ---- host ---- ================================================ FILE: src/main/asciidoc/inc/start/_overview.adoc ================================================ [[start-overview]] This goal creates and starts docker containers. This goal evaluates the configuration's `` section of all given (and enabled images). Also you can specify `docker.follow` as system property so that the `{plugin}:start` will never return but block until CTRL-C is pressed. That similar to the option `-i` for `docker run`. This will automatically switch on `showLogs` so that you can see what is happening within the container. Also, after stopping with CTRL-C, the container is stopped (but not removed so that you can make postmortem analysis). `{plugin}:run` is an alias for `{plugin}:start` with `docker.follow` enabled. By default container specific properties are exposed as Maven properties. These properties have the format `docker.container..` where `` is the name of the container (see below) and `` is one of the following container properties: .Properties provided [cols="1,5"] |=== | Property | Description | *ip* | Internal IP address of the container. | *id* | Container id | *net*.__.*ip* | Internal IP address of the container in the specified custom network. This works only for custom networks. |=== Instead of the `` a fixed property key can be configured in the image's < >> configuration with the option `exposedPropertyKey`. For example the Maven property `docker.container.tomcat.ip` would hold the Docker internal IP for a container with an alias "tomcat". You can set the global configuration *exposeContainerInfo* to an empty string to not expose container information that way or to a string for an other prefix than `docker.container`. ================================================ FILE: src/main/asciidoc/inc/start/_port-mapping.adoc ================================================ The `` configuration contains a list of port mappings. Whitespace is trimmed from each element and empty elements are ignored. Each mapping has multiple parts, each separate by a colon. This is equivalent to the port mapping when using the Docker CLI with option `-p`. A `port` stanza may take one of the following forms: .Port mapping format [cols="2,5"] |=== | Format | Description | ++18080:8080++ | Tuple consisting of two numeric values separated by a `:`. This form will result in an explicit mapping between the docker host and the corresponding port inside the container. In the above example, port 18080 would be exposed on the docker host and mapped to port 8080 in the running container. | **host.port**++:80++ | Tuple consisting of a string and a numeric value separated by a `:`. In this form, the string portion of the tuple will correspond to a Maven property. If the property is undefined when the `start` task executes, a port will be dynamically selected by Docker in the ephemeral port range and assigned to the property which may then be used later in the same POM file. The ephemeral port range is configured by the `/proc/sys/net/ipv4/ip_local_port_range` kernel parameter, which typically ranges from 32678 to 61000. If the property exists and has numeric value, that value will be used as the exposed port on the docker host as in the previous form. In the above example, the docker service will elect a new port and assign the value to the property `host.port` which may then later be used in a property expression similar to `${host.port}`. This can be used to pin a port from the outside when doing some initial testing similar to `mvn -Dhost.port=10080 {plugin}:start` | **bindTo**++:++**host.port**++:80++ | Tuple consisting of two strings and a numeric value separated by a `:`. In this form, `bindTo` is an ip address on the host the container should bind to. As a convenience, a hostname pointing to the docker host may also be specified. The container will fail to start if the hostname can not be resolved. | +**host.ip**++:++**host.port**++:80++ | Tuple consisting of two strings and a numeric value separated by a `:`. In this form, the host ip of the container will be placed into a Maven property name `host.ip`. If docker reports that value to be `0.0.0.0`, the value of `docker.host.address` will be substituted instead. In the event you want to use this form and have the container bind to a specific hostname/ip address, you can declare a Maven property of the same name (`host.ip` in this example) containing the value to use. `host:port` works in the same way as described above. |=== By default TCP is used as protocol but you can also use UDP by appending '/udp' to the port number. The following are examples of valid configuration entries: .Example [source,xml] ---- 1.2.3.4 some.host.pvt ... 18080:8080 15060:5060/udp host.port:80 127.0.0.1:80:80 localhost:host.port:80 +container.ip.property:host.port:5678 +bind.host.ip:host.port:5678 +bind.host.name:5678:5678 ---- Another useful configuration option is `portPropertyFile` which can be used to write out the container's host ip and any dynamic ports that have been resolved. The keys of this property file are the property names defined in the port mapping configuration and their values those of the corresponding docker attributes. This property file might be useful with tests or with other maven plugins that will be unable to use the resolved properties because they can only be updated after the container has started and plugins resolve their properties in an earlier lifecycle phase. If you don't need to write out such a property file and thus don't need to preserve the property names, you can use normal maven properties as well. E.g. `${host.var}:${port.var}:8080` instead of `+host.var:port.var:8080`. ================================================ FILE: src/main/asciidoc/inc/start/_restart.adoc ================================================ Specify the behavior to apply when the container exits. These values can be specified withing a `` section with the following sub-elements: .Restart Policy configuration [cols="1,5"] |=== | Element | Description | *name* a| Restart policy name, choose from: * `always` (_v1.15_) always restart * `on-failure` (_v1.15_) restart on container non-exit code of zero | *retry* | If `on-failure` is used, controls max number of attempts to restart before giving up. |=== The behavior to apply when the container exits. The value is an object with a name property of either "always" to always restart or "on-failure" to restart only when the container exit code is non-zero. If on-failure is used, MaximumRetryCount controls the number of times to retry before giving up. The default is not to restart. (optional) ================================================ FILE: src/main/asciidoc/inc/start/_volumes.adoc ================================================ A container can bind (or "mount") volumes from various source when starting up: Either from a directory of the host system or from another container which exports one or more directories. The mount configuration is specified within a `` section of the run configuration. It can contain the following sub elements: .Volume configuration [cols="1,5"] |=== | Element | Description | *from* | List of `` elements which specify image names or aliases of containers whose volumes should be imported. | *bind* | List of `` specifications (or _host mounts_). Use `/path` to create and expose a new volume in the container, `/host_path:/container_path` to mount a host path into the container and `/host_path:/container_path:ro` to bind it read-only. |=== .Volumes example [source,xml] ---- /logs /opt/host_export:/opt/container_import jolokia/docker-demo ---- In this example the container creates a new volume named `/logs` on the container and mounts `/opt/host_export` from the host as `/opt/container_import` on the container. In addition all exported volumes from the container which has been created from the image `jolokia/docker-demo` are mounted directly into the container (with the same directory names under which the exporting container exposes these directories). This image must be also configured for this plugin. Instead of the full image name, an alias name can be used, too. If a volume name instead of a path is referenced to in `` and a <> exists with this name, then this this volume is created upfront with the provided options instead of using default options. You can use Maven variables in the path specifications. This should even work for boot2docker and docker-machine: .Example with absolute paths [source,xml] ---- ${project.build.directory}/${project.artifactId}-${project.version}:/usr/local/tomcat/webapps/${project.name} ${project.basedir}/data:/data ---- You can also use relative paths. Relative paths are interpreted relative to the Maven project base directory. Paths that begin with `~` are interpreted relative to the JVM's `user.home` directory. .Example with relative paths [source,xml] ---- src/main/webapps/foo:/usr/local/tomcat/webapps/foo ./target:/data ~:/home/user ~/.m2/repository:/home/user/.m2/repository ---- If you wish to mount volumes from an existing container not managed by the plugin, you may do by specifying the container name obtained via `docker ps` in the configuration. ================================================ FILE: src/main/asciidoc/inc/start/_wait.adoc ================================================ While starting a container is it possible to block the execution until some condition is met. These conditions can be specified within a `` section which the following sub-elements: .Wait configuration [cols="1,5"] |=== | Element | Description | *http* a| HTTP ping check which periodically polls an URL. It knows the following sub-elements: * *url* holds an URL and is mandatory * *method* Optional HTTP method to use. * *status* Status code which if returned is considered to be a successful ping. This code can be given either as a single number (200) or as a range (200..399). The default is `200..399` * *allowAllHosts* If `url` is an HTTPS url and this option is set, then server certificates are not validated. By default they are checked for a proper CA signature. | *log* | Regular expression which is applied against the log output of an container and blocks until the pattern is matched. You can use `(?s)` in the pattern to switch on multi line matching. | *time* | Time in milliseconds to block. | *kill* | Time in milliseconds between sending `SIGTERM` and `SIGKILL` when stopping a container. Since docker itself uses second granularity, you should use at least 1000 milliseconds. | *shutdown* | Time to wait in milliseconds between stopping a container and removing it. This might be helpful in situation where a Docker croaks with an error when trying to remove a container to fast after it has been stopped. | *exec* a| Commands to execute during specified lifecycle of the container. It knows the following sub-elements: * *postStart* Command to run after the above wait criteria has been met * *preStop* Command to run before the container is stopped. * *breakOnError* If set to `true` then break the build if a `postStart` or `preStop` command exits with an return code other than 0, otherwise only print an error message. | *tcp* a| TCP port check which periodically polls given tcp ports. It knows the following sub-elements: * *mode* can be either `mapped` which uses the mapped ports or `direct` in which case the container ports are addressed directly. In the later case the host field should be left empty in order to select the container ip (which must be routed which is only the case when running on the Docker daemon's host directly). Default is `direct` when host is _localhost_, `mapped` otherwise. The direct mode might help when a so called _user-proxy_ is enabled on the Docker daemon which makes the mapped ports directly available even when the container is not ready yet. * *host* is the hostname or the IP address. It defaults to `${docker.host.address}` for a mapped mode and the container ip address for the direct mode. * *ports* is a list of TCP ports to check. These are supposed to be the container internal ports. | *healthy* a| Check that waits until the container health state becomes `healthy`. A container is considered healthy when its <> succeeds. This behaviour mimics the docker compose dependsOn `condition: service_healthy`. | *exit* | Check that waits until a container finishes with the given exit code. |=== As soon as one condition is met the build continues. If you add a `