jenkinsci / jenkinsci/docker-workflow-plugin

[JENKINS-54389] Containers with ENTRYPOINT is not started correctly

Open
#588 10 comments 0 reactions 0 assignees View on GitHub
component:docker-workflow-plugin imported-jira-issue priority:blocker resolution:unresolved
Dominant language
Java
Stars
527
Forks
422
Avg merge
10m
Merged PRs (30d)
1

Description

I try to add some service startup to Dockerfile ENTRYPOINT.

But Jenkins starts container with `cat` CMD and immediately check `cat` in `docker ps` output. As result, there are race condition between `docker ps` and ENTRYPOINT script.

I created minimalistic example for reproducing this issue on stock Jenkins: https://github.com/bozaro/jenkins-docker-issue

This example contains:



  1. Dockerfile declaring ENTRYPOINT:

FROM alpine:latest

COPY entry.sh /opt/bin/
ENTRYPOINT ["/opt/bin/entry.sh"]
CMD ["/bin/sh"]


  1. ENTRYPOINT script with 3 seconds delay and creating marker file:

#!/bin/sh -ex

# Starting very important services...
sleep 3
# Service is ready now
echo > /tmp/ready
exec "$@"


  1. Jenkinsfile running container with marker file check:

pipeline {

agent {
dockerfile {
filename 'Dockerfile'
}
}
stages {
stage('Check file') {
steps {
sh "cat /tmp/ready"
}
}
}
}

Expected result for Jenkins test:



  1. At least a 3-second delay on pipeline withDockerContainer step

  2. ENTRYPOINT script output in build output;

  3. Green build

Actual result for Jenkins test:



  1. False positive error message:

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).



  1. Failed "Check file" step because ENTRYPOINT is not completed yet and /tmp/ready file is not exists;

  2. There are no ENTRYPOINT script output in build.

Theoretically this issue can be solved if Jenkins would send some random string marker to docker container and wait this marker in container output.

---
Originally reported by bozaro, imported from: Containers with ENTRYPOINT is not started correctly


  • status: Open
  • priority: Blocker
  • component(s): docker-workflow-plugin
  • resolution: Unresolved
  • votes: 18
  • watchers: 24
  • imported: 2025-12-07

Raw content of original issue

I try to add some service startup to Dockerfile ENTRYPOINT.

But Jenkins starts container with `cat` CMD and immediately check `cat` in `docker ps` output. As result, there are race condition between `docker ps` and ENTRYPOINT script.

I created minimalistic example for reproducing this issue on stock Jenkins: https://github.com/bozaro/jenkins-docker-issue

This example contains:



  1. Dockerfile declaring ENTRYPOINT:


FROM alpine:latest

COPY entry.sh /opt/bin/
ENTRYPOINT ["/opt/bin/entry.sh"]
CMD ["/bin/sh"]



  1. ENTRYPOINT script with 3 seconds delay and creating marker file:


#!/bin/sh -ex

# Starting very important services...
sleep 3
# Service is ready now
echo > /tmp/ready
exec "$@"



  1. Jenkinsfile running container with marker file check:


pipeline {

agent {
dockerfile {
filename 'Dockerfile'
}
}
stages {
stage('Check file') {
steps {
sh "cat /tmp/ready"
}
}
}
}


Expected result for Jenkins test:



  1. At least a 3-second delay on pipeline withDockerContainer step

  2. ENTRYPOINT script output in build output;

  3. Green build

Actual result for Jenkins test:



  1. False positive error message:

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).



  1. Failed "Check file" step because ENTRYPOINT is not completed yet and /tmp/ready file is not exists;

  2. There are no ENTRYPOINT script output in build.

Theoretically this issue can be solved if Jenkins would send some random string marker to docker container and wait this marker in container output.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.