Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use docker because of the plugin default CMD #7

Open
SylvestreMassalaz opened this issue Aug 14, 2015 · 4 comments
Open

Unable to use docker because of the plugin default CMD #7

SylvestreMassalaz opened this issue Aug 14, 2015 · 4 comments

Comments

@SylvestreMassalaz
Copy link

Hi there,
I currently have a problem when using this image that seems to come from the docker plugin configuration.

Either I leave the CMD field unmodified and the docker command fails because the startup script is not launched or I try to set it to the startup script and the SSH connection fails.

I didn't find any hints in the plugin documentation, but I noticed that the default command doesn't looks like the default one (see the result i got from a docker inspect below):

  • The default one
"Path": "bash",
"Args": [
    "-c",
      "/usr/sbin/sshd -D -p 22"
],
  • The custom one
"Path": "/jenkins-slave-startup.sh",
"Args": [],

Does anyone know how to set it correctly?

@mattrobenolt
Copy link
Contributor

We do this:

We have an image that uses this as it's base, so something like:

FROM tehranian/dind-jenkins-slave

COPY docker-entrypoint.sh /entrypoint
ENTRYPOINT ["/entrypoint"]

Then our docker-entrypoint.sh:

#!/bin/bash
set -e

case "$1" in
  image | test | deploy)
    cd /home/jenkins && exec wrapdocker sudo -EHsu jenkins ci-${1}.sh;
esac

exec wrapdocker "$@"

Basically, everything just needs to call wrapdocker which is what controls starting the daemon in the background.

Does that make sense?

@tehranian
Copy link
Owner

@mattrobenolt Is changing our Dockerfile to work better out of the box an option?

@mattrobenolt
Copy link
Contributor

Likely, I'm not even sure why sshd is needed tbh since we don't use it.

But I'd rather let @branden answer better since he mostly works on this stuff. I'm just a spectator mostly. :)

@SylvestreMassalaz
Copy link
Author

Hi, thanks for your response!

Sadly, I'm still unable to make it work correctly, this time even with the default command set by the jenkins docker plugin.

As you can see I only added a few things when starting from your example

FROM tehranian/dind-jenkins-slave
MAINTAINER Sylvestre Massalaz <[email protected]>

ENV YML_DIR /etc/pl/

RUN curl -L -k https://github.com/docker/compose/releases/download/1.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose &&\
    chmod +x /usr/local/bin/docker-compose

RUN apt-get update &&\
    apt-get install -y \
      wget \
      curl \
      unzip

COPY pl-deploy-test/* ${YML_DIR}

COPY compose-entrypoint.sh /entrypoint

RUN chmod +x /entrypoint

ENTRYPOINT ["/entrypoint"]

My entrypoint is also really simple

#! /bin/bash

set -e

exec wrapdocker "$@"

When it's launched with the plugin default command, I get this with docker inspect

    "Path": "/entrypoint",
    "Args": [
        "bash",
        "-c",
        "/usr/sbin/sshd -D -p 22"

Then I tried to remove the bash (the command being already inside an exec) and I mannually set it to
/usr/sbin/sshd -D, the ni got

    "Path": "/entrypoint",
    "Args": [
        "/usr/sbin/sshd",
        "-D"
    ],

Either way, the container is created by Jenkins but the SSH connexion seems to fail because it shows offline and never starts the build.

The only setting I made on the template configuration is checking "run privileged" as asked in the readme.

Any Idea?

Edit : I think that the error with ssh has something to do with the fact that wrapdocker seems to take a while, maybe never launching the default command. Maybe we should use a smaller version that only does the basic configuration and daemon starting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants