I have been unsuccessful running a docker container with systemd from a jenkins pipeline without getting the following 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).
Alternatively you can force image entrypoint to be disabled by adding option `--entrypoint=''`.
Pipeline:
pipeline {
agent {
docker {
image "centos/systemd"
args "--entrypoint='/usr/sbin/init' -u root -v /sys/fs/cgroup:/sys/fs/cgroup --privileged"
}
}
options {
ansiColor('xterm')
skipDefaultCheckout(true)
timestamps ()
}
stages {
stage('Test systemctl') {
steps {
sh ' systemctl' }
}
}
}
It seems that jenkins is stealing any option of a CMD
arg and putting in cat
. Which seems foolish because /usr/sbin/init
needs to be the first thing run. Ideally as the CMD
.