无法创建 docker 访问对象

nol*_*ole 8 spring maven docker fabric8

我想使用 Fabric8 插件进行 Spring 集成测试,但是当我尝试运行测试时出现下一个错误:

无法创建 docker 访问对象

我有 ubuntu,我认为我有配置良好的 docker,我在 dockerfiles 或 dockercompose 方面没有遇到任何问题,所以可能是权限问题或者我忘记了一些东西。

我过去的 Fabric8 配置如下,其中有 mysql 的映像和用于集成测试的 maven-failsafe-plugin。

<!--maven plugin -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <environmentVariables>
                    <it-database.port>${it-database.port}</it-database.port>
                </environmentVariables>
            </configuration>
        </plugin>
        <!--fabric8 plugin -->
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>0.18.1</version>
            <configuration>
                <!--<dockerHost>unix:///var/run/docker.sock</dockerHost>-->
                <dockerHost>tcp://0.0.0.0:2375</dockerHost>
            </configuration>
            <executions>
                <execution>
                    <id>prepare-it-database</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                    <configuration>
                        <images>
                            <image>
                                <name>mysql:5.7</name>
                                <alias>it-database</alias>
                                <run>
                                    <ports>
                                        <port>it-database.port:5432</port>
                                    </ports>
                                    <wait>
                                        <log>database system is ready to accept connections</log>
                                        <time>20000</time>
                                    </wait>
                                </run>
                            </image>
                        </images>
                    </configuration>
                </execution>
                <execution>
                    <id>remove-it-database</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
Run Code Online (Sandbox Code Playgroud)

Jam*_*han 1

您确定 docker 守护进程正在侦听端口 2375 吗?您可能想尝试在 pom.xml 中使用 localhost 或 127.0.0.1 而不是 0.0.0.0。

你可以输入

   env | grep DOCKER
Run Code Online (Sandbox Code Playgroud)

这也可能是一个糟糕的环境变量