jenkinsci / docker-plugin

Jenkins cloud plugin that uses Docker
https://plugins.jenkins.io/docker-plugin/
MIT License
489 stars 319 forks source link

Default command is /usr/sbin/sshd -D #105

Closed bartmeuris closed 9 years ago

bartmeuris commented 10 years ago

When starting a container and the command is empty, "/usr/sbin/sshd -D" is automatically added as CMD. However, my containers already use "/usr/sbin/sshd -D" as ENTRYPOINT - which makes sshd quit because it receives an unknown parameter "/usr/sbin/sshd".

ENTRYPOINTS and CMD's in docker work as following: ENTRYPOINT and CMD are appended when launching a container. CMD can be overridden on commandline by simply providing parameters. ENTRYPOINT can be overriddden with the --entrypoint cmdline flag.

*Using version 0.8 of the plugin

arienkock commented 10 years ago

entrypoints are meant as a way to customize the execution of commands. making sshd -D your entrypoint seems odd and I think adjusting your images makes more sense than any other fix. If that's not an option. Maybe try adding a non empty Docker command in the plugin config that isn't a param and doesn't do anything? e.g. ; echo nop

bartmeuris commented 10 years ago

My point is that the plugin cannot handle images which specify an entrypoint. It just blindly passes "/usr/sbin/sshd -D" as a command without even caring what runs inside the container.

Some of my jenkins build images also run supervisord to launch separate services required to complete the build, next to sshd. The plugin attempting to launch sshd automagically screws this up too, I now have to wrap all commands in a script that just ignores all parameters passed to it and set is as entrypoint - losing a lot of flexibility.

Some of my images are also based on other images which already specify an entrypoint for running services. If I don't re-specify the ssh daemon as entrypoint, my default service would be launched with the "/usr/sbin/sshd -D" parameter - which is even more "wrong".

That the option would exist to automatically attempt to start sshd would be fine, but then it would have to do this by overriding the entrypoint, otherwise this will still conflict with existing images.

EDIT: To clarify: I use as entrypoint "/usr/sbin/sshd" and as command "-D" in my jenkins build images - which is how it's intended to be used.

samrocketman commented 9 years ago

That does not appear to be the behavior in my container. I'm using phusion/baseimage and I'm passing in /sbin/my_init. It is starting it correctly rather than do as @arienkock suggests.

jpgxs commented 9 years ago

In the image's advanced configuration, specify Docker Command as "--"

KostyaSha commented 9 years ago

Is it still actual?