The plugin determines which Docker registry to use for push and pull operations based on the image name and configuration hierarchy.
Image Name Semantics
If the image name contains a registry part (everything before the first / that contains a . or :), that registry is used unconditionally and cannot be overwritten.
Default Registry Resolution
If the image name does not contain a registry part, the plugin follows this resolution order to find a registry:
- Image-specific configuration: The
<registry> subelement within an <image> block. - Global configuration: The
<registry> element in the plugin configuration, or the system property -Ddocker.registry. - Environment variable: The
DOCKER_REGISTRY environment variable. - Default: If none of the above are provided,
docker.io is used.
Fine-grained Control (Pull vs. Push)
You can specify different registries for pulling (e.g., for base images during build) and pushing. This is useful when your base images come from one source but your final images are pushed to a private registry.
To separate pull and push registries, use:
- Configuration:
<pullRegistry> and <pushRegistry> elements. - System Properties:
docker.pull.registry and docker.push.registry.
Note: If you provide a registry via command line (e.g., mvn -Ddocker.registry=myregistry:5000 ...), it will be used for both operations unless fine-grained settings are provided.
<configuration>
<registry>docker.jolokia.org:443</registry>
<images>
<image>
<!-- Without an explicit registry ... -->
<name>jolokia/jolokia-java</name>
<!-- ... hence use this registry -->
<registry>docker.ro14nd.de</registry>
</image>
<image>
<name>postgresql</name>
<!-- No registry in the name, hence use the globally
configured docker.jolokia.org:443 as registry -->
</image>
<image>
<!-- Explicitely specified always wins -->
<name>docker.example.com:5000/another/server</name>
</image>
</images>
</configuration>