我一直在尝试在我的 Mac 上构建我的 Maven spring boot 项目的 Docker 映像。
这是我的构建部分:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
<executions>
<execution>
<id>build-image</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>tag-image</id>
<phase>package</phase>
<goals>
<goal>tag</goal>
</goals>
<configuration>
<image>my-image</image>
<newName>registry.example.com/my-image</newName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
当我运行这个命令时: mvn -X package docker:build
我收到此错误:
[ERROR] Failed to execute goal
com.spotify:docker-maven-plugin:0.4.13:build (build-image)
on project Spring-Boot-ReceiverAPI: Exception caught:
Request error:
POST unix://localhost:80/build?t=uptake/Spring-Boot-ReceiverAPI: 500: HTTP 500 Internal Server Error -> [Help 1]
这是我的 DOCKER_HOST:
echo $DOCKER_HOST
unix:///private/var/run/docker.sock
所有其他 docker 命令运行良好:
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 384ed96af950 4 hours ago 640.9 MB
java 8 96cddf5ae9f1 10 days ago 640.9 MB
containersol/minimesos-cli 0.10.2 0f8fd0fee007 8 weeks ago 133.7 MB
Docker 守护进程显然正在运行,并且 DOCKER_HOST 的值适用于正常的 Docker 命令。
我该怎么做才能使 docker build 在 Mac 上运行?