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

cat command in docker agents not detected correctly

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: docker-workflow-plugin
    • Labels:
      None
    • Environment:
      Jenkins 2.104 on Docker 17.10.0-ce on CentOS 7.4.1708 (Kernel 3.10.0-693.2.2.el7.x86_64)
    • Similar Issues:

      Description

      When using a declarative Jenkins pipeline with a stage that uses a Docker agent, I get a confusing error message in the Jenkins log:

      $ docker top 08e1c013e07083492ad0f03285f1a7d30063fb15e0cf39be7b55af6d1a03c829
      ERROR: The container started but didn't run the expected command. Please double check your ENTRYPOINT does execute the command passed as docker run argument. See https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#entrypoint for entrypoint best practices.
      

      The build continues normally and the cat command is actually running inside the container, so everything is fine except that the error message occurs although it shouldn't.

      Comparing the code in listProcess in https://github.com/jenkinsci/docker-workflow-plugin/blob/master/src/main/java/org/jenkinsci/plugins/docker/workflow/client/DockerClient.java with the output of docker top shows the likely cause of that error:

      docker top prints the following fields

      UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
      build               19799               19784               0                   22:23               pts/0               00:00:00            cat
      

      However, the Java client assumes that only PID, USER, TIME and COMMAND is printed. I suggest that the process list is determined by using an explicit format specifier like

      docker container top ${CONTAINER_ID} -eo pid,comm
      

        Attachments

          Issue Links

            Activity

            Hide
            thxmasj Thomas Johansen added a comment -

            Chisel Wright: The problem seems to be isolated to Docker for Windows. I don't have the problem on 17.12 on Ubuntu.

            Show
            thxmasj Thomas Johansen added a comment - Chisel Wright : The problem seems to be isolated to Docker for Windows. I don't have the problem on 17.12 on Ubuntu.
            Hide
            chizcw Chisel Wright added a comment -

            My earlier comment was missing the version and OS - sorry.

            17.12.0-ce on Centos/AWS (2017.09)

             

             

            Show
            chizcw Chisel Wright added a comment - My earlier comment was missing the version and OS - sorry. 17.12.0-ce on Centos/AWS (2017.09)    
            Hide
            ndeloof Nicolas De Loof added a comment -

            Chisel Wright no, this just means docker runtime has some issues, and some are fixed in recent releases. docker-workflow-plugin uses docker CLI and expect it to run by the reference documentation.

            Show
            ndeloof Nicolas De Loof added a comment - Chisel Wright no, this just means docker runtime has some issues, and some are fixed in recent releases. docker-workflow-plugin uses docker CLI and expect it to run by the reference documentation.
            Hide
            thxmasj Thomas Johansen added a comment -

            For the record; I also get the invalid syntax error on Docker for Windows 18.02 now. It is obviously related to the large pids bug.

            Show
            thxmasj Thomas Johansen added a comment - For the record; I also get the invalid syntax error on Docker for Windows 18.02 now. It is obviously related to the large pids bug.
            Hide
            jglick Jesse Glick added a comment -

            Release notes ought to mention that 1.15.1 works for docker.image('maven:3.5.0').inside but not docker.image('maven:3.3.9').inside, for example. I presume that is a result of this commit by Carlos Sanchez.

            Show
            jglick Jesse Glick added a comment - Release notes ought to mention that 1.15.1 works for docker.image('maven:3.5.0').inside but not docker.image('maven:3.3.9').inside , for example. I presume that is a result of this commit by Carlos Sanchez .

              People

              • Assignee:
                ndeloof Nicolas De Loof
                Reporter:
                hendrikhalkow Hendrik Halkow
              • Votes:
                0 Vote for this issue
                Watchers:
                31 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: