hashicorp / nomad-driver-lxc

HashiCorp Nomad LXC driver plugin
Mozilla Public License 2.0
31 stars 19 forks source link

config: command is not supported? #18

Closed onlyjob closed 5 years ago

onlyjob commented 5 years ago

Apparently driver-lxc do not understand "command" keyword in the "config" section.

How can I run an arbitrary command in LXC container?

Is LXC driver not suitable for batch jobs?

Limitations and use cases should be documented.

tgross commented 5 years ago

Hi @onlyjob!

Typically I've seen LXC used primarily for "system containers" (sometimes referred to as "machine containers"). From their own website:

Our main focus is system containers. That is, containers which offer an environment as close as possible as the one you'd get from a VM but without the overhead that comes with running a separate kernel and simulating all the hardware.

Usually that includes running something like systemd or runit or supervisord as PID1 in the container to determine what services are going to be run.

That being said, I think you probably want to use the template field to pass the appropriate set of instructions for the container to execute.

onlyjob commented 5 years ago

Thank you for explanation. But template takes exactly one parameter so there seems to be no way to pass any parameters other than volumes and the name of the template...

tgross commented 5 years ago

It looks like LXC is expecting extra args to be passed into the template, and I checked the API of library we're using here and there's a TemplateOptions.ExtraArgs parameter. But then I dug into the codebase here and it turns out we do allow a template_args parameter which gets passed to the LXC create call at lxc/lxc.go#L229!

So this looks like there's some missing documentation on the Nomad website. If you'd like to contribute a patch to the LXC driver docs that'd be awesome. Otherwise I'll try to do that shortly.

onlyjob commented 5 years ago

Awesome. Thanks, @tgross.

I probably won't be able to contribute anything any time soon. Please do not wait for me...

tgross commented 5 years ago

I've opened https://github.com/hashicorp/nomad/pull/6640 with that documentation update.

onlyjob commented 5 years ago

Thanks for preparing this merge request. I could not possibly provide that much information as I did not know any of that...

tgross commented 5 years ago

Published https://www.nomadproject.io/docs/drivers/external/lxc.html

onlyjob commented 5 years ago

Thank you.