MattyW
MattyW

Reputation: 1529

How should I install custom packages in an lxc container?

I would like to start a container with the basic ubuntu template - but I'd like it to automatically install a couple of extra packages - or ideally run a bash script.

It seems like I should be using hooks, and when I create a container pass in a configuration file which sets a particular hook as my bash script. But I can't help but think there must be an easier way?

Upvotes: 2

Views: 2171

Answers (1)

stgraber
stgraber

Reputation: 256

Recent versions of the lxc-ubuntu template supports a --packages option which lets you get extra packages in there.

Otherwise, you can indeed use a start hook to run stuff inside the container.

If using the ubuntu-cloud template, you could also pass it a cloud-init config file which can do that kind of stuff for you.

Or if you just want to always do the same kind of configuration, simply create an ubuntu container, start it, customize it to your liking and from that point on, just use lxc-clone instead of lxc-create to create new containYou can indeeders based on the one you customized.

Upvotes: 2

Related Questions