Docker build in Jenkins

When running job with Docker build and publish I get exception Please find the exception below

git config core.sparsecheckout # timeout=10
git checkout -f 82bb778d55f0a9a5020c23aa5dfa62db79de2e28
git rev-list 82bb778d55f0a9a5020c23aa5dfa62db79de2e28 # timeout=10 [example]

  • Why containers network throughput is low
  • cant run boot2docker in win 7 64bit strange virtual box error
  • Running docker chrome node in EC2 Does Not Download Files
  • Unable to find image '7111.mithun:latest' locally Error response from daemon: repository 7111.mithun not found: does not exist or no pull access
  • Self hosted kibana 5.1.1 showing blank pages after connected to AWS Elasticsearch 5.1.1
  • Dockerized MongoDB on Heroku?
  • $ docker build -t adithi11/demo-example:v9 –pull=true /Users/Shared/Jenkins/Home/workspace/example

    ERROR: Cannot run program "docker" (in directory "/Users/Shared/Jenkins/Home/workspace/example"): error=2, No such file or directory
    java.io.IOException: Cannot run program "docker" (in directory "/Users/Shared/Jenkins/Home/workspace/example"): error=2, No such file or directory
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
        at hudson.Proc$LocalProc.<init>(Proc.java:245)
        at hudson.Proc$LocalProc.<init>(Proc.java:214)
        at hudson.Launcher$LocalLauncher.launch(Launcher.java:846)
        at hudson.Launcher$ProcStarter.start(Launcher.java:384)
        at com.cloudbees.dockerpublish.DockerBuilder$Perform.executeCmd(DockerBuilder.java:487)
        at com.cloudbees.dockerpublish.DockerBuilder$Perform.executeCmd(DockerBuilder.java:431)
        at com.cloudbees.dockerpublish.DockerBuilder$Perform.buildAndTag(DockerBuilder.java:373)
        at com.cloudbees.dockerpublish.DockerBuilder$Perform.exec(DockerBuilder.java:311)
        at com.cloudbees.dockerpublish.DockerBuilder$Perform.access$100(DockerBuilder.java:291)
        at com.cloudbees.dockerpublish.DockerBuilder.perform(DockerBuilder.java:262)
        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:1728)
        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
        at hudson.model.ResourceController.execute(ResourceController.java:98)
        at hudson.model.Executor.run(Executor.java:404)
    Caused by: java.io.IOException: error=2, No such file or directory
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
        at java.lang.ProcessImpl.start(ProcessImpl.java:134)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
        ... 19 more
    Build step 'Docker Build and Publish' marked build as failure
    Finished: FAILURE
    

    But when i sudo to jenkins I get this

    sudo su jenkins
    docker images
    Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.25/images/json: dial unix /var/run/docker.sock: connect: permission denied

    Would appreciate your assistance

  • How to populate table by commands in the Dockerfile
  • Run a complex series of commands in the same Docker container
  • Connecting to Kubernetes on Docker on OSX?
  • How can i create a folder inside the shared volume with the correct permission in docker?
  • can't restart docker after resetting the docker socker using docker -H tcp://0.0.0.0:2375
  • How to specify different .dockerignore files for different builds in the same project?
  • One Solution collect form web for “Docker build in Jenkins”

    # Add the docker group if it doesn't already exist.
    $ sudo groupadd docker
    
    # Add jenkins user to docker group. 
    $ sudo gpasswd -a jenkins docker
    
    # Restart the Docker daemon.
    $ sudo service docker restart
    

    Logout and login again for the changes to apply

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.