简体   繁体   English

使用Fabric8部署Java项目

[英]Using Fabric8 to Deploy a Java Project

I am trying to use Fabric8 to build an image for my Java application. 我正在尝试使用Fabric8为我的Java应用程序构建映像。 However, I am new and this could be a duplicate question. 但是,我是新手,这可能是一个重复的问题。

I have docker installed and the fabric8 library added via maven. 我安装了docker,并通过maven添加了fabric8库。

Below is my initial setup for the fabric maven plugin. 下面是我对fabric maven插件的初始设置。

<plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <configuration>
                            <dockerHost>/var/run/docker.sock</dockerHost>
                            <images>
                                <image>
                                    <alias>${project.artifactId}</alias>
                                    <name></name>
                                    <build>
                                        <from>java:8</from>
                                        <maintainer>${project.maintainer}</maintainer>
                                        <dockerFile>${project.basedir}/Dockerfile</dockerFile>
                                        <dockerHost>/var/run/docker.sock</dockerHost>
                                        <ports>
                                            <port>8080</port>
                                            <port>8081</port>
                                        </ports>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Below is the error message I am getting. 以下是我收到的错误消息。

Unable to parse configuration of mojo io.fabric8:docker-maven-plugin:0.30.0:build for parameter dockerHost: Cannot find 'dockerHost' in class io.fabric8.maven.docker.config.BuildImageConfiguration

Try to remove the dockerHost element from the image build configuration. 尝试从映像构建配置中删除dockerHost元素。 There is no such option for the build configuration . 构建配置没有这样的选项。

dockerHost specifies the connection to the Docker host, ie the machine where the image is going to be built and eventually run. dockerHost指定与Docker主机的连接,即将要构建并最终运行映像的计算机。 This option is not actually needed unless the plugin cannot determine it by itself. 除非插件无法自行确定,否则实际上不需要此选项。 The discovery sequence is detailed in the Global Configuration section of the docs . 发现序列在文档的“全局配置”部分中详细说明。

If you build with maven on the machine where the docker daemon runs, you normally don't need this configuration. 如果在运行docker守护程序的计算机上使用maven构建,则通常不需要此配置。 The plugin will connect to the unix socket /var/run/docker.sock which is the default URL of the docker daemon. 该插件将连接到unix socket /var/run/docker.sock ,这是docker守护程序的默认URL。

If the requirement is to run the image on a remote host, then you either specify the dockerHost option or the DOCKER_HOST environment variable. 如果要求是在远程主机上运行映像,则指定dockerHost选项或DOCKER_HOST环境变量。 On the host, the docker daemon must be configured for remote access. 在主机上,必须配置docker守护程序以进行远程访问。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM