Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Add dockerCertPath option to allow SSL connection to dockerHost #216

Merged
merged 1 commit into from
Apr 20, 2016

Conversation

lorellalou
Copy link
Contributor

This PR allows to specify the path to the Docker Certificates created by docker-machine.

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <configuration>
        <dockerHost>${docker.host}</dockerHost>
        <dockerCertPath>${docker.cert.path}</dockerCertPath>
    </configuration>
</plugin>

The properties can be defined with a Maven profile in settings.xml

<profile>
    <id>docker</id>
       <properties>
           <docker.host>https://192.168.99.100:2376</docker.host
           <docker.cert.path>/Users/me/.docker/machine/machines/default</docker.cert.path>
       </properties>
</profile>

This can address #177 without ENV, only Properties in Maven profiles

@@ -93,10 +96,13 @@ public void setUp() {
@Test
public void testDockerHostSet() throws Exception {
ReflectionTestUtils.setField(sut, "dockerHost", DOCKER_HOST);
ReflectionTestUtils.setField(sut, "dockerCertPath", DOCKER_CERT_PATH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would also be fine to make the field protected and add @VisibleForTesting to it

@mattnworb
Copy link
Member

This change LGTM, I'm just curious about the use case - docker-maven-plugin constructs the DockerClient by calling DefaultDockerClient.fromEnv() which will set the certificate path to the path pointed to by the environment variable DOCKER_CERT_PATH, if it is set.

What would be the advantage in configuring this via Maven properties or the plugin <configuration> block instead of an environment variable?

@davidxia
Copy link
Contributor

That's a good point. I'd rather have one way of setting the cert path.

@lorellalou
Copy link
Contributor Author

lorellalou commented Apr 20, 2016

@mattnworb if I want to manage several docker hosts I can use docker-machine env before invoking Maven. But I think it is more appropriate to manage these docker hosts using a Maven Profile (you can't set ENV in a Maven Profile). And since you already provide the dockerHost config, I think that allowing to set also dockerCertPath is more consistent.

@mattnworb
Copy link
Member

@lrolaz sounds reasonable to me, thanks for the explanation

@mattnworb mattnworb merged commit 45f4795 into spotify:master Apr 20, 2016
@lorellalou lorellalou deleted the docker-cert-path branch April 25, 2016 14:19
@chariut
Copy link

chariut commented Jun 17, 2016

Your solution would work only if I build locally, where I have control over my host. What would be the dockerHost and dockerCertPath values for dockerHUB? I have similar issues when I run my build in dockerHub.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants