Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-35025

Container command '/bin/cat' not found or does not exist

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I'm using Jenkins as a Docker container by installing Docker within my Jenkins container and binding Docker socket (see config below).
      I try to compile a Maven project using maven:3.2-jdk-7 (see attached image).
      But I have this error:

      $ docker run --rm --entrypoint /bin/true alpine:3.2
      $ docker run --tty --rm --entrypoint /sbin/ip alpine:3.2 route
      $ docker run --tty --detach --workdir /var/jenkins_home/jobs/xxxxx/workspace --volume /var/jenkins_home:/var/jenkins_home:rw --volume /tmp:/tmp:rw --net bridge --add-host dockerhost:172.17.0.1 --env BUILD_DISPLAY_NAME=#1 --env BUILD_ID=1 --env BUILD_NUMBER=1 --env BUILD_TAG=xxxxx-1 --env BUILD_URL=http://localhost:8080/job/xxxxx/1/ --env CLASSPATH= --env EXECUTOR_NUMBER=0 --env GIT_BRANCH=origin/master --env GIT_COMMIT=883d20d67b50b0daea5a78d3192a4f84ed282fb4 --env GIT_URL=https://git.xxxxxxxx.git --env HUDSON_HOME=/var/jenkins_home --env HUDSON_SERVER_COOKIE=70042bb5dbdea6c1 --env HUDSON_URL=http://localhost:8080/ --env JENKINS_SERVER_COOKIE=70042bb5dbdea6c1 --env JENKINS_URL=http://localhost:8080/ --env JOB_NAME=xxxxx --env JOB_URL=http://localhost:8080/job/xxxxx/ --env NODE_LABELS=master --env NODE_NAME=master --env WORKSPACE=/var/jenkins_home/jobs/xxxxx/workspace maven:3.2-jdk-7 /bin/cat
      docker: Error response from daemon: Container command '/bin/cat' not found or does not exist..
      FATAL: Failed to run docker image
      java.lang.RuntimeException: Failed to run docker image
      	at com.cloudbees.jenkins.plugins.docker_build_env.Docker.runDetached(Docker.java:226)
      	at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.startBuildContainer(DockerBuildWrapper.java:202)
      	at com.cloudbees.jenkins.plugins.docker_build_env.DockerBuildWrapper.setUp(DockerBuildWrapper.java:175)
      	at hudson.model.Build$BuildExecution.doRun(Build.java:156)
      	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
      	at hudson.model.Run.execute(Run.java:1738)
      	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      	at hudson.model.ResourceController.execute(ResourceController.java:98)
      	at hudson.model.Executor.run(Executor.java:410)
      Finished: FAILURE
      

      I don't understand why I have this error as I'm able to compile my project locally using this Maven Docker image.

      Here is my config:

      Dockerfile

      FROM jenkins:1.651.2
      
      USER root
      
      RUN \
        apt-get update && \
        apt-get install -y apt-transport-https ca-certificates && \
        echo "deb https://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list && \
        apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && \
        apt-get update && \
        apt-get install -y \
          lxc \
          sudo \
          docker-engine \
          bzip2 && \
        usermod -a -G docker jenkins
      
      RUN chown -R jenkins "$JENKINS_HOME" /usr/share/jenkins/ref
      
      USER jenkins
      

      docker-compose.yml

      jenkins:
        build: .
        ports:
          - "8080:8080"
          - "5000:5000"
        volumes:
          - /var/run/docker.sock:/var/run/docker.sock
      

        Attachments

          Activity

          Hide
          willseward Wills Ward added a comment -

          David Chua I noticed that too.

          Have you tried copying the build command directly into the cli on a build server to see if the workdir is your problem too?

          Show
          willseward Wills Ward added a comment - David Chua I noticed that too. Have you tried copying the build command directly into the cli on a build server to see if the workdir is your problem too?
          Hide
          cleankod Adam Cleankod added a comment -

          Did anyone find a solution to this problem? I'm having the same issue and executing the command directly does not have this issue.

          Show
          cleankod Adam Cleankod added a comment - Did anyone find a solution to this problem? I'm having the same issue and executing the command directly does not have this issue.
          Hide
          amilstead Alex Milstead added a comment - - edited

          I'm not 100% sure why this is happening, but I had the same issue and was able to work around it by modifying my entrypoint.

          I changed it to:

          ENTRYPOINT ["/bin/bash", "-c"]
          

          It might have something to do with the other options going into the run command? Not totally positive. Either way, using "-c" accepts the command (i.e. /bin/cat) as text to execute in the context of a shell, rather than whatever it's doing without that.

          Show
          amilstead Alex Milstead added a comment - - edited I'm not 100% sure why this is happening, but I had the same issue and was able to work around it by modifying my entrypoint. I changed it to: ENTRYPOINT [ "/bin/bash" , "-c" ] It might have something to do with the other options going into the run command? Not totally positive. Either way, using "-c" accepts the command (i.e. /bin/cat) as text to execute in the context of a shell, rather than whatever it's doing without that.
          Hide
          amilstead Alex Milstead added a comment -

          To be clear: I was able to control the Dockerfile definition of the image being run for the build.

          Show
          amilstead Alex Milstead added a comment - To be clear: I was able to control the Dockerfile definition of the image being run for the build.
          Hide
          sachin771 sachin gupta added a comment -

          is there any resolution to this issue, we are also facing the same issue even in Jenkins version 2.161

          Show
          sachin771 sachin gupta added a comment - is there any resolution to this issue, we are also facing the same issue even in Jenkins version 2.161

            People

            • Assignee:
              Unassigned
              Reporter:
              cthiebault Cedric Thiebault
            • Votes:
              2 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated: