如何为Jenkins找到Docker REST API URI

时间:2016-06-29 15:07:34

标签: jenkins docker centos

我在CentOS机器上运行Jenkins。我有一个工作,拉动Github仓库,并使用Jenkins的Docker插件构建Docker镜像。当我尝试运行该作业时,我收到错误:

ERROR: Build step failed with exception
java.lang.NullPointerException: uri was not specified
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
    at com.github.dockerjava.core.DockerClientConfig$DockerClientConfigBuilder.withUri(DockerClientConfig.java:406)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.createDockerClient(DockerBuilder.java:120)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.getDockerClient(DockerBuilder.java:204)
    at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:68)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1720)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Build step 'Execute Docker command' marked build as failure

如何找到此URI?当我运行sudo netstat -tunlp时,我看不到任何地方的码头工人。此外,this page提到Docker守护程序侦听unix:///var/run/docker.sock。我该如何解决这个问题?

这是我的Dockerfile,供参考:

FROM ubuntu:15.04

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y  software-properties-common && \
    add-apt-repository ppa:webupd8team/java -y && \
    apt-get update && \
    echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true\
 | /usr/bin/debconf-set-selections && \
    apt-get install -y oracle-java8-installer && \
    apt-get clean

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get -y install openjdk-8-jdk && \
    apt-get -y install sudo && \
    apt-get -y install curl && \
    apt-get -y install jq && \
    apt-get clean

# Add our Java code. Use COPY command so that jar file stays compressed.
COPY myJavaApp.jar myJavaApp.jar

# Add the shell script
ADD script.sh .

# Add env info file
ADD envInfo .

# Set permissions for shell script and execute it, generating the application.properties file within the current Docker image layer.
RUN sudo chmod 755 script.sh && sudo ./script.sh

EXPOSE 8080  

# Upon container startup, execute the JAR with the appropriate parameters
ENTRYPOINT ["java", "-Dspring.profiles.active=sierra", \
            "-Dspring.config.location='file:application.properties'", \
            "-jar", "myJavaApp.jar", "--debug", \
            "--spring.config.location=file:application.properties"]

0 个答案:

没有答案