Newbie question: what's the lxc version of a Dockerfile?

@votsalo

So I reject your rejection of cloud-init :laughing:

Given the following scenario:

  • Script to setup webhost
  • Additional drives & devices

You could do the following

Profile A - Setup Webhost

Create a file containing

#cloud-config

# Apply updates using apt
package_update: true
package_upgrade: true

# Install packages
packages:
 - apache2
 - php-common
 - php7.2
 - libapache2-mod-php7.2

runcmd:
 - timedatectl set-timezone Europe/London
 - rm -rf /etc/apache2/sites-available/default-ssl.conf
 - DO_A_BUNCH_OF_OTHER STUFF

then import this into a profile lxc profile PROFILE_NAME set user.user-data - < FILE_LOCATION

How this is less “monolithic and different from everything else linux.” than a DockerFile which may contain lines like the one below is beyond me

RUN apt-get update -y && apt-get install -y - apache2 php-common php7.2 libapache2-mod-php7.2
RUN timedatectl set-timezone Europe/London &&  rm -rf /etc/apache2/sites-available/default-ssl.conf

The lines can also get harder to read (if people don’t properly line break them) as you try to reduce the number of “layers” in your docker image

Now if your going to argue “id just make my own docker image” then just go and make your own LXD image and optionally don’t bother with cloud-init.

Profile B - Disks & Devices

Create as many profiles as you need with different device & disk declarations (I’m not gonna repeat the documentation here)

You could even include the extra disk definitions in the same profile as the cloud-config instructions (as all containers of this “type” need the same disks right?)

Creating a Container

Well now all our provisioning info is in profiles its as simple as

lxc launch ubuntu: c1 -p PROFILE_WITH_CLOUD_INIT -p PROFILE/S_WITH_DISKS_OR_DEVICES

VS Docker

Compared with docker-compose this is not as simple no, you would just run docker-composer and it would locate the file/s and run it.

But docker still requires a docker-composer.yml (disks & devices) & DockerFile (user.user-data) the only difference between LXD & Docker is that LXD stores this info in a database instead of flat files!

Lack Cloud-init Images

This used to be true, but there was a lot of work to bundle in cloud-init to the images

A lot of the provided images now have cloud-init variants and alpine was / is one of them (3.12 support coming soon?)