我从昨天起就被封锁了,需要一些帮助。我尝试使用jenkins docker-plugin
和docker-plugin-step
从dockerfile构建docker镜像。
然而,当我尝试运行jenkins作业时,它给了我以下异常:
Docker Build
Docker Build : build with tag jdubois/jhipster-docker:Gateway_Jenkins_V1 at path /home/javateam/DockerfileGateway
ERROR: Build step failed with exception
java.lang.NullPointerException: config was not specified
at shaded.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:226)
at com.github.dockerjava.core.DockerClientImpl.<init>(DockerClientImpl.java:36)
at com.github.dockerjava.core.DockerClientImpl.getInstance(DockerClientImpl.java:52)
at com.github.dockerjava.core.DockerClientBuilder.getInstance(DockerClientBuilder.java:29)
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run$1.invoke(DockerBuilderPublisher.java:144)
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run$1.invoke(DockerBuilderPublisher.java:139)
at hudson.FilePath.act(FilePath.java:991)
at hudson.FilePath.act(FilePath.java:969)
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.buildImage(DockerBuilderPublisher.java:139)
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher$Run.run(DockerBuilderPublisher.java:89)
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderPublisher.perform(DockerBuilderPublisher.java:180)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.build(MavenModuleSetBuild.java:915)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:866)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1744)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:374)
Build step 'Build / Publish Docker Containers' marked build as failure
Finished: FAILURE
以下是dockerfile内容:
#Basic images for Gateway MS
FROM jdubois/jhipster-docker:Gateway_Jenkins_V1
#Fetch last Gateway MS version from gitlab and run it
RUN cd /home/jhipster/DockerJenkinsGateway && \
git pull origin master
# expose the working directory, the Tomcat port, the BrowserSync ports, the SSHD port, and run SSHD
VOLUME ["/jhipster"]
EXPOSE 8080 3000 3001 22
CMD /usr/sbin/sshd -D
出错了什么?
答案 0 :(得分:1)
另一个选择是使用Jenkins提供的shell作为构建步骤,并使用通常在该shell脚本中使用的命令行参数构建Docker镜像。
这就是我们在构建服务器上所做的事情,它为我们提供了对版本控制和推送到Dockerhub的图像/标记之类的细粒度控制。
答案 1 :(得分:0)
如果您使用的是Jenkins 2.0或更高版本,那么Jenkins会为您提供构建管道作为代码的选项,您可以轻松地集成docker及其存储库。
转到 - &gt;新项目 - &gt;选择多分支管道选项,您将看到通过Jenkins连接到docker的选项。
如有更多详情,请告诉我。