[JIRA] (JENKINS-51307) Declarative pipeline and docker entrypoint

1,056 views
Skip to first unread message

zougi.fr@gmail.com (JIRA)

unread,
May 14, 2018, 2:12:02 PM5/14/18
to jenkinsc...@googlegroups.com
Frederic Rousseau created an issue
 
Jenkins / New Feature JENKINS-51307
Declarative pipeline and docker entrypoint
Issue Type: New Feature New Feature
Assignee: vjuranek
Components: docker-build-step-plugin
Created: 2018-05-14 18:11
Environment: problem occurs on version 1.15 and above of the plugin
Priority: Major Major
Reporter: Frederic Rousseau

I write a dead simple Dockerfile

 

FROM openjdk:8-jdk-alpine
ENTRYPOINT "java"

 

I write a dead simple declarative pipeline

pipeline {
    agent { dockerfile true }
    stages {
        stage('Dead Simple') {
            steps {
                checkout scm
            }
        }
    }
 }

I get an error.

I get the same error with 

pipeline {
    agent { docker 'openjdk:8-jdk-alpine' }
    stages {
        stage('Dead Simple') {
            steps {
                checkout scm
            }
        }
    }
}

The error is

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, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.

I cannot pass --entrypoint to the run command, it's jenkins that call it

a bit more logs :

[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 107:111 -w /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:rw,z -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** 4d6ffe9d9713df374dd2670073b9ea32598df407 cat
$ docker top 13d063e7996ad4476075baf7586aa3186d0bff08cdbd4c10205327bb6b44c75b -eo pid,comm
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, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

zougi.fr@gmail.com (JIRA)

unread,
May 14, 2018, 2:13:01 PM5/14/18
to jenkinsc...@googlegroups.com
Frederic Rousseau updated an issue
Change By: Frederic Rousseau
I write a dead simple Dockerfile

 
{code:java}

FROM openjdk:8-jdk-alpine
ENTRYPOINT "java"
{code}

 

I write a dead simple declarative pipeline
{code:java}

pipeline {
    agent { dockerfile true }
    stages {
        stage('Dead Simple') {
            steps {
                checkout scm
            }
        }
    }
}{code}

I get an error.

I get the same error with 
{code:java}

pipeline {
    agent { docker 'openjdk:8-jdk-alpine' }
    stages {
        stage('Dead Simple') {
            steps {
                checkout scm
            }
        }
    }
}{code}
The error is
{code:java}

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, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.
{code}
I cannot pass --entrypoint to the run command, it's jenkins that
call calls it

a bit more logs :
{code:java}

[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 107:111 -w /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:rw,z -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** 4d6ffe9d9713df374dd2670073b9ea32598df407 cat
$ docker top 13d063e7996ad4476075baf7586aa3186d0bff08cdbd4c10205327bb6b44c75b -eo pid,comm
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, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.
{code}

zougi.fr@gmail.com (JIRA)

unread,
May 14, 2018, 2:14:02 PM5/14/18
to jenkinsc...@googlegroups.com
Frederic Rousseau updated an issue
Change By: Frederic Rousseau
Issue Type: New Feature Bug

zougi.fr@gmail.com (JIRA)

unread,
May 14, 2018, 2:15:03 PM5/14/18
to jenkinsc...@googlegroups.com
Frederic Rousseau updated an issue
I cannot pass --entrypoint to the run command, it's jenkins that calls it


a bit more logs :
{code:java}
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 107:111 -w /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:rw,z -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** 4d6ffe9d9713df374dd2670073b9ea32598df407 cat
$ docker top 13d063e7996ad4476075baf7586aa3186d0bff08cdbd4c10205327bb6b44c75b -eo pid,comm
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, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.
{code}

zougi.fr@gmail.com (JIRA)

unread,
May 14, 2018, 3:13:01 PM5/14/18
to jenkinsc...@googlegroups.com
Frederic Rousseau updated an issue
I write a dead simple Dockerfile
{code:java}
FROM openjdk:8-jdk-alpine
ENTRYPOINT "java"
{code}
I write a dead simple declarative pipeline
{code:java}
pipeline {
    agent { dockerfile true }
    stages {
        stage('Dead Simple') {
            steps {
                checkout scm
            }
        }
    }
}{code}
I get an error.

I get the same error with 
{code:java}
pipeline {
    agent { docker { image 'openjdk:8-jdk-alpine' } }
    stages {
        stage('Dead Simple') {
            steps {
                checkout scm
            }
        }
    }
}{code}
The error is
{code:java}
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, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.
{code}
I cannot pass --entrypoint to the run command, it's jenkins that calls it

a bit more logs :
{code:java}
[Pipeline] withDockerContainer
Jenkins does not seem to be running inside a container
$ docker run -t -d -u 107:111 -w /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA:rw,z -v /var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:/var/lib/jenkins/workspace/oh-pr0009-api_master-IFYDNFODANQT2HMWSAOO6P6UKZZUCWSO2LNM2M6G7DUPGPLNH7HA@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** 4d6ffe9d9713df374dd2670073b9ea32598df407 cat
$ docker top 13d063e7996ad4476075baf7586aa3186d0bff08cdbd4c10205327bb6b44c75b -eo pid,comm
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, as required by official docker images (see https://github.com/docker-library/official-images#consistency for entrypoint consistency requirements).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.
{code}

zougi.fr@gmail.com (JIRA)

unread,
May 22, 2018, 8:00:01 AM5/22/18
to jenkinsc...@googlegroups.com
Frederic Rousseau assigned an issue to Jesse Glick
Change By: Frederic Rousseau
Assignee: vjuranek Jesse Glick

zougi.fr@gmail.com (JIRA)

unread,
May 22, 2018, 8:00:02 AM5/22/18
to jenkinsc...@googlegroups.com
Frederic Rousseau updated an issue
Change By: Frederic Rousseau
Component/s: docker-workflow-plugin
Component/s: docker-build-step-plugin

zougi.fr@gmail.com (JIRA)

unread,
May 22, 2018, 9:22:01 AM5/22/18
to jenkinsc...@googlegroups.com
Frederic Rousseau commented on Bug JENKINS-51307
 
Re: Declarative pipeline and docker entrypoint

Hey Jesse, I saw you were working on this plugin and took the liberty to assign you this issue. When I first opened it, I chose the wrong component. The right one is docker-workflow-plugin. Cheers

jglick@cloudbees.com (JIRA)

unread,
Jun 5, 2018, 7:21:01 PM6/5/18
to jenkinsc...@googlegroups.com
Jesse Glick resolved as Not A Defect
 

As noted in the error message, this is not a valid entrypoint.

Change By: Jesse Glick
Status: Open Resolved
Resolution: Not A Defect

michal.matyjek@gmail.com (JIRA)

unread,
Jun 15, 2018, 1:05:02 AM6/15/18
to jenkinsc...@googlegroups.com
Michal Matyjek commented on Bug JENKINS-51307
 
Re: Declarative pipeline and docker entrypoint

It seems with these changes we are making things more complex. What could have been a simple purpose-built container to perform very specific task (regardless if ran on Jenkins or wherever) now requires extra scripting to meet https://github.com/docker-library/official-images#consistency

I would argue that some containers used in pipelines will never become official.

Anyways, I'd like to leave my solution here in case someone hits this issue:

I used to have in my Dockerfile:

ENTRYPOINT [ "python", "./my_script.py" ]

To make it work, added a new script (`./entrypoint,sh`):

#!/bin/sh
set -e

# check if there was a command passed
# required by Jenkins Docker plugin: https://github.com/docker-library/official-images#consistency
if [ "$1" ]; then
    # execute it
    exec "$@"
fi

# else run my script
exec python ./my_script.py

And changed the Dockerfile:

ADD entrypoint.sh /

ENTRYPOINT [ "/entrypoint.sh" ]

You people are smart, you can come with nicer solutions. But I got that goin' for me, which is nice. Thanks Jesse Glick and others for all the hard work on this stuff!

jglick@cloudbees.com (JIRA)

unread,
Jun 15, 2018, 4:56:01 PM6/15/18
to jenkinsc...@googlegroups.com

you can come with nicer solutions

It is being worked on. The withDockerContainer step (including its agent docker Declarative sugar) should be avoided I think; it just never worked consistently enough to be an advertised feature.

zougi.fr@gmail.com (JIRA)

unread,
Jun 25, 2018, 1:18:02 AM6/25/18
to jenkinsc...@googlegroups.com
Frederic Rousseau reopened an issue
 
Change By: Frederic Rousseau
Resolution: Not A Defect
Status: Resolved Reopened
Assignee: Jesse Glick Carlos Sanchez
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

zougi.fr@gmail.com (JIRA)

unread,
Jun 25, 2018, 1:18:03 AM6/25/18
to jenkinsc...@googlegroups.com
Frederic Rousseau commented on Bug JENKINS-51307
 
Re: Declarative pipeline and docker entrypoint

Carlos Sanchez what do you think about this issue? docker maven doesn't work out of the box on declarative pipeline https://github.com/carlossg/docker-maven/ 

Michal Matyjek, your solution I find intrusive. I prefer to do the following to build my dockers. It's Ugly but the problem comes from Jenkins, I prefer to fix it in Jenkinsfile

    agent {
        dockerfile {
            args '--entrypoint=\'\''
        }
    }

pieter@pietervogelaar.nl (JIRA)

unread,
Aug 6, 2018, 7:11:02 AM8/6/18
to jenkinsc...@googlegroups.com
Pieter Vogelaar edited a comment on Bug JENKINS-51307
Thanks [~zougi], I search searched a lot on the internet and I finally found this Jira issue. I couldn't understand why nginx wasn't listening inside the container. But I guess Jenkins doesn't execute by default the entrypoint/CMD of de Docker image. This fixed it for me:
{code:java}
customImage.inside("-u root --entrypoint='/start.sh'") {}
{code}

pieter@pietervogelaar.nl (JIRA)

unread,
Aug 6, 2018, 7:11:02 AM8/6/18
to jenkinsc...@googlegroups.com

Thanks Frederic Rousseau, I search a lot on the internet and I finally found this Jira issue. I couldn't understand why nginx wasn't listening inside the container. But I guess Jenkins doesn't execute by default the entrypoint/CMD of de Docker image. This fixed it for me:

customImage.inside("-u root --entrypoint='/start.sh'") {}

owen@nerdnetworks.org (JIRA)

unread,
Mar 26, 2019, 12:10:58 AM3/26/19
to jenkinsc...@googlegroups.com

We have seen in two different cases that upgrading to 1.15.1 fixes this issue. 

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

owen@nerdnetworks.org (JIRA)

unread,
Mar 26, 2019, 12:11:01 AM3/26/19
to jenkinsc...@googlegroups.com

owen@nerdnetworks.org (JIRA)

unread,
Apr 8, 2019, 10:25:03 PM4/8/19
to jenkinsc...@googlegroups.com
Owen Mehegan updated an issue
 
Change By: Owen Mehegan
Comment:
We have seen in two different cases that upgrading to 1.15.1 fixes this issue. 

sschuberth@gmail.com (JIRA)

unread,
Jun 18, 2019, 12:06:02 PM6/18/19
to jenkinsc...@googlegroups.com
Sebastian Schuberth commented on Bug JENKINS-51307
 
Re: Declarative pipeline and docker entrypoint

Note that https://github.com/docker-library/official-images#consistency, point 3, says "If the image only contains the main executable and its linked libraries (ie no shell) then it is fine to use the executable as the ENTRYPOINT". So using cat as the command is not a valid consistency check.

How can I just run the defined ENTRYPOINT, optionally passing arguments, but not have any steps defined?

jglick@cloudbees.com (JIRA)

unread,
Jun 18, 2019, 1:16:02 PM6/18/19
to jenkinsc...@googlegroups.com

How can I just run the defined ENTRYPOINT, optionally passing arguments, but not have any steps defined?

sh 'docker run --rm my-image some-arg'

timblaktu@gmail.com (JIRA)

unread,
Jan 15, 2020, 4:27:05 PM1/15/20
to jenkinsc...@googlegroups.com

Sebastian Schuberth, regarding your comment on using `cat` as a docker command, I see in the OP and in my own pipeline examples that the `cat` command is specified at the end of `docker run` and I cannot figure out why. Any info would be helpful.

For example, the following pipeline code:
 

docker_image.inside("<other args>")  {   ... }

 
results in the following docker run command, which has inserted a cat command at the end. 
 

docker run -t -d -u 118:124 <other args...> <image-name> cat    

I believe this might be the reason why when I specify a CMD and/or ENTRYPOINT in our Dockerfile, it isn't working. Perhaps this is inserted by Jenkins under some circumstance?

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

timblaktu@gmail.com (JIRA)

unread,
Jan 15, 2020, 4:28:03 PM1/15/20
to jenkinsc...@googlegroups.com
Tim Black edited a comment on Bug JENKINS-51307
[~sschuberth], regarding your comment on using `cat` as a docker command, I see in the OP and in my own pipeline examples that the `cat` command is specified at the end of `docker run` and I cannot figure out why. Any info would be helpful.


For example, the following pipeline code:
 
{code:java}
docker_image.inside("<other args>")  {   ... }{code}

 
results in the following docker run command, which has inserted a {{cat}} command at the end. 
 
{code:java}
docker run -t -d -u 118:124 <other args...> <image-name> cat    {code}

I believe this might be the reason why when I specify a CMD and/or ENTRYPOINT in our Dockerfile, it isn't working. Perhaps this is inserted by Jenkins under some circumstance?

timblaktu@gmail.com (JIRA)

unread,
Jan 15, 2020, 4:54:06 PM1/15/20
to jenkinsc...@googlegroups.com
Tim Black edited a comment on Bug JENKINS-51307
[~sschuberth], regarding your comment on using `cat` as a docker command, I see in the OP and in my own pipeline examples that the `cat` command is specified at the end of `docker run` and I cannot figure out why. Any info would be helpful.

For example, the following pipeline code:
 
{code:java}
docker_image.inside("<other args>")  {   ... }{code}
 
results in the following docker run command, which has inserted a {{cat}} command at the end. 
 
{code:java}
docker run -t -d -u 118:124 <other args...> <image-name> cat    {code}
I believe this might be the reason why when I specify a CMD and/or ENTRYPOINT in our Dockerfile, it isn't working. Perhaps this is inserted by Jenkins under some circumstance?


UPDATE: I have since found this PR: [https://github.com/jenkinsci/docker-workflow-plugin/pull/116] which discussion confirms the explicit forcing of CMD to `cat`.

It is still woefully unclear to me how to specify, in a Dockerfile, how to run a command every time the docker image is run, when using Jenkins/Docker "inside()" pipeline.
Reply all
Reply to author
Forward
0 new messages