A closer look at Minimal Ubuntu for LXD

Here is the announcement of the release of Minimal Ubuntu for public clouds and Docker Hub.

Minimal Ubuntu is similar to Ubuntu Server, but with much less packages. Among the packages that are gone, it’s documentation packages, locales and other user-oriented packages. Obviously, you can install whichever packages you need. That is, for any package that may be missing from the container image, you can just install it yourself.

Minimal Ubuntu is to be used in Virtual Machines (VMs) and containers. You want the smallest possible base image that you can add packages as needed. And you want the experience of managing it to still be Ubuntu.

In the following we are going to use these new Minimal Ubuntu images in LXD.

Setting up LXD to use Minimal Ubuntu cloud images

There is a separate LXD remote (a repository of cloud images) that has the Minimal Ubuntu cloud images. Therefore, to use Minimal Ubuntu cloud images, we just need to add this remote to our LXD installation. As shown below, the name of the remote is ubuntu-minimal:.

$ lxc remote add --protocol simplestreams ubuntu-minimal https://cloud-images.ubuntu.com/minimal/releases/

Viewing the Minimal Ubuntu cloud images

Let’s view the available images  of the ubuntu-minimal: remote. We will be using the lxc image subcommand in the following to extract as much information as possible.

$ lxc image list ubuntu-minimal:
+------------+--------------+--------+-----------------------------------------------------+--------+---------+------------------------------+
| ALIAS      | FINGERPRINT  | PUBLIC | DESCRIPTION                                         | ARCH   | SIZE    | UPLOAD DATE                  |
+------------+--------------+--------+-----------------------------------------------------+--------+---------+------------------------------+
| b (5 more) | ca484a77810d | yes    | ubuntu 18.04 LTS amd64 (minimal release) (20180705) | x86_64 | 92.76MB | Jul 5, 2018 at 12:00am (UTC) |
+------------+--------------+--------+-----------------------------------------------------+--------+---------+------------------------------+
| x (9 more) | 35b4044b3fa7 | yes    | ubuntu 16.04 LTS amd64 (minimal release) (20180705) | x86_64 | 93.08MB | Jul 5, 2018 at 12:00am (UTC) |
+------------+--------------+--------+-----------------------------------------------------+--------+---------+------------------------------+

There are two cloud images, xenial and bionic, for Ubuntu 16.04 LTS and Ubuntu 18.04 LTS respectively.

They are about 93MB in size and they were generated on the 5th July 2018.

Each image has a fingerprint (hash) that uniquely identifies it.

When launching containers using these images, we can either use one of the aliases (b for bionic, x for xenial). There are 5 extra for bionic and 9 extra for xenial. But what are the rest of the aliases?

Viewing the aliases of the images

Let’s view all the aliases of the images.

There are six specific aliases for each container image, and there four generic aliases. The specific aliases have either a reference to the version of Ubuntu or the codename (either x/xenial or b/bionic). The generic aliases are default, default/amd64, lts and lts/amd64 and currently point to Ubuntu 16.04.

$ lxc image alias list ubuntu-minimal:
+---------------+--------------+-------------+
| ALIAS         | FINGERPRINT  | DESCRIPTION |
+---------------+--------------+-------------+
| 16.04         | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| 16.04/amd64   | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| 18.04         | ca484a77810d |             |
+---------------+--------------+-------------+
| 18.04/amd64   | ca484a77810d |             |
+---------------+--------------+-------------+
| b             | ca484a77810d |             |
+---------------+--------------+-------------+
| b/amd64       | ca484a77810d |             |
+---------------+--------------+-------------+
| bionic        | ca484a77810d |             |
+---------------+--------------+-------------+
| bionic/amd64  | ca484a77810d |             |
+---------------+--------------+-------------+
| default       | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| default/amd64 | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| lts           | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| lts/amd64     | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| x             | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| x/amd64       | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| xenial        | 35b4044b3fa7 |             |
+---------------+--------------+-------------+
| xenial/amd64  | 35b4044b3fa7 |             |
+---------------+--------------+-------------+

We can reference these cloud images using any of the aliases.

Viewing more details on container images

Let’s see more details on the two container images.

We can now see the full fingerprint, timestamps about the expiration of the image and when they were last used, image properties and the full list of aliases.

$ lxc image info ubuntu-minimal:18.04
Fingerprint: ca484a77810debc59dc59052f7ad6172daaf5d81551a5164f6c76f0ff7b15e90
Size: 92.76MB
Architecture: x86_64
Public: yes
Timestamps:
   Created: 2018/07/05 00:00 UTC
   Uploaded: 2018/07/05 00:00 UTC
   Expires: 2023/04/26 00:00 UTC
   Last used: never
Properties:
   version: 18.04
   architecture: amd64
   label: minimal release
   serial: 20180705
   description: ubuntu 18.04 LTS amd64 (minimal release) (20180705)
   os: ubuntu
   release: bionic
Aliases:
   - 18.04
   - 18.04/amd64
   - b
   - b/amd64
   - bionic
   - bionic/amd64
Cached: no
Auto update: disabled
$ lxc image info ubuntu-minimal:16.04
Fingerprint: 35b4044b3fa7fdd450444f81a74a69be4a1d71c1e7a36eb587049514b658aee9
Size: 93.08MB
Architecture: x86_64
Public: yes
Timestamps:
   Created: 2018/07/05 00:00 UTC
   Uploaded: 2018/07/05 00:00 UTC
   Expires: 2021/04/21 00:00 UTC
   Last used: never
Properties:
   release: xenial
   version: 16.04
   architecture: amd64
   label: minimal release
   serial: 20180705
   description: ubuntu 16.04 LTS amd64 (minimal release) (20180705)
   os: ubuntu
Aliases:
   - 16.04
   - 16.04/amd64
   - x
   - x/amd64
   - xenial
   - xenial/amd64
   - lts
   - lts/amd64
   - default
   - default/amd64
Cached: no
Auto update: disabled

There is also the lxc image info subcommand, but shows only a subset of the info of the lxc image show subcommand.

$ lxc image show ubuntu-minimal:16.04
auto_update: false
properties:
  architecture: amd64
  description: ubuntu 16.04 LTS amd64 (minimal release) (20180705)
  label: minimal release
  os: ubuntu
  release: xenial
  serial: "20180705"
  version: "16.04"
public: true
$ lxc image show ubuntu-minimal:18.04
auto_update: false
properties:
  architecture: amd64
  description: ubuntu 18.04 LTS amd64 (minimal release) (20180705)
  label: minimal release
  os: ubuntu
  release: bionic
  serial: "20180705"
  version: "18.04"
public: true

Launching a container

Let’s launch a container, with Minimal Ubuntu, version 18.04. The full name of the container image is ubuntu-minimal:18.04 (remote name and an image alias).

$ lxc launch ubuntu-minimal:18.04 minimal
Creating minimal
Starting minimal

Here is the container running,

$ lxc list minimal --columns ns4
+---------+---------+----------------------+
| NAME    | STATE   | IPV4                 |
+---------+---------+----------------------+
| minimal | RUNNING | 10.50.250.50 (eth0)  |
+---------+---------+----------------------+

Getting a shell to the container

Use the lxc exec subcommand to get a shell into the container.

$ lxc exec minimal -- sudo --user ubuntu --login
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@minimal:~$

We got a shell. Let’s add a screenshot as well so that I can use it as a feature image for this blog post.

The screenshot shows us that

  • the prompt has color, therefore there is text color in Minimal Ubuntu!
  • There are three locales, the default one is C.UTF-8.
  • there is no vi, which is OK because we can install straight away vim. Install with
    sudo apt install vim
  • there is no man command.

 

Difference between C.UTF-8 and en_US.UTF-8

In most cases, you would be using the en_US.UTF-8 locale. How does it differ from the C.UTF-8 locale?

ubuntu@minimal:~$ diff -u C.UTF-8.out en_US.UTF-8.out 
--- C.UTF-8.out 2018-07-10 20:52:43.749331836 +0000
+++ en_US.UTF-8.out 2018-07-10 21:03:36.663558953 +0000
@@ -37,26 +37,26 @@
ctype-outdigit7_wc=55
ctype-outdigit8_wc=56
ctype-outdigit9_wc=57
-ctype-translit-tab-size=1603
-ctype-translit-default-missing-len=0
+ctype-translit-tab-size=5929
+ctype-translit-default-missing-len=1
ctype-translit-ignore-len=0
ctype-translit-ignore=""
map-to-nonascii=0
nonascii-case=0
decimal_point="."
-thousands_sep=""
-grouping=-1
+thousands_sep=","
+grouping=3;3
numeric-decimal-point-wc=46
-numeric-thousands-sep-wc=0
+numeric-thousands-sep-wc=44
numeric-codeset="UTF-8"
abday="Sun;Mon;Tue;Wed;Thu;Fri;Sat"
day="Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday"
abmon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
mon="January;February;March;April;May;June;July;August;September;October;November;December"
am_pm="AM;PM"
-d_t_fmt="%a %b %e %H:%M:%S %Y"
-d_fmt="%m/%d/%y"
-t_fmt="%H:%M:%S"
+d_t_fmt="%a %d %b %Y %r %Z"
+d_fmt="%m/%d/%Y"
+t_fmt="%r"
t_fmt_ampm="%I:%M:%S %p"
era=
era_year=""
@@ -68,7 +68,7 @@
time-era-entries="S"
week-ndays=7
week-1stday=19971130
-week-1stweek=4
+week-1stweek=1
first_weekday=1
first_workday=2
cal_direction=1
@@ -77,104 +77,104 @@
time-codeset="UTF-8"
alt_mon="January;February;March;April;May;June;July;August;September;October;November;December"
ab_alt_mon="Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec"
-collate-nrules=1
-collate-rulesets=""
-collate-symb-hash-sizemb=1
+collate-nrules=4
+collate-rulesets=""
+collate-symb-hash-sizemb=2707
collate-codeset="UTF-8"
-int_curr_symbol=""
-currency_symbol=""
+int_curr_symbol="USD "
+currency_symbol="$"
mon_decimal_point="."
-mon_thousands_sep=""
-mon_grouping=-1
+mon_thousands_sep=","
+mon_grouping=3;3
positive_sign=""
-negative_sign=""
-int_frac_digits=-1
-frac_digits=-1
-p_cs_precedes=-1
-p_sep_by_space=-1
-n_cs_precedes=-1
-n_sep_by_space=-1
-p_sign_posn=-1
-n_sign_posn=-1
-crncystr="-"
-int_p_cs_precedes=-1
-int_p_sep_by_space=-1
-int_n_cs_precedes=-1
-int_n_sep_by_space=-1
-int_p_sign_posn=-1
-int_n_sign_posn=-1
-duo_int_curr_symbol=""
-duo_currency_symbol=""
-duo_int_frac_digits=-1
-duo_frac_digits=-1
-duo_p_cs_precedes=-1
-duo_p_sep_by_space=-1
-duo_n_cs_precedes=-1
-duo_n_sep_by_space=-1
-duo_int_p_cs_precedes=-1
-duo_int_p_sep_by_space=-1
-duo_int_n_cs_precedes=-1
-duo_int_n_sep_by_space=-1
-duo_p_sign_posn=-1
-duo_n_sign_posn=-1
-duo_int_p_sign_posn=-1
-duo_int_n_sign_posn=-1
+negative_sign="-"
+int_frac_digits=2
+frac_digits=2
+p_cs_precedes=1
+p_sep_by_space=0
+n_cs_precedes=1
+n_sep_by_space=0
+p_sign_posn=1
+n_sign_posn=1
+crncystr="-$"
+int_p_cs_precedes=1
+int_p_sep_by_space=1
+int_n_cs_precedes=1
+int_n_sep_by_space=1
+int_p_sign_posn=1
+int_n_sign_posn=1
+duo_int_curr_symbol="USD "
+duo_currency_symbol="$"
+duo_int_frac_digits=2
+duo_frac_digits=2of the 
+duo_p_cs_precedes=1
+duo_p_sep_by_space=0
+duo_n_cs_precedes=1
+duo_n_sep_by_space=0
+duo_int_p_cs_precedes=1
+duo_int_p_sep_by_space=1
+duo_int_n_cs_precedes=1
+duo_int_n_sep_by_space=1
+duo_p_sign_posn=1
+duo_n_sign_posn=1
+duo_int_p_sign_posn=1
+duo_int_n_sign_posn=1
uno_valid_from=10101
uno_valid_to=99991231
duo_valid_from=10101
duo_valid_to=99991231
conversion_rate=1;1
monetary-decimal-point-wc=46
-monetary-thousands-sep-wc=0
+monetary-thousands-sep-wc=44
monetary-codeset="UTF-8"
-yesexpr="^[yY]"
-noexpr="^[nN]"
-yesstr=""
-nostr=""
+yesexpr="^[+1yY]"
+noexpr="^[-0nN]"
+yesstr="yes"
+nostr="no"
messages-codeset="UTF-8"
-height=297
-width=210
+height=279
+width=216
paper-codeset="UTF-8"
-name_fmt="%p%t%g%t%m%t%f"
+name_fmt="%d%t%g%t%m%t%f"
name_gen=""
-name_mr=""
-name_mrs=""
-name_miss=""
-name_ms=""
+name_mr="Mr."
+name_mrs="Mrs."
+name_miss="Miss."
+name_ms="Ms."
name-codeset="UTF-8"
-postal_fmt="%a%N%f%N%d%N%b%N%s %h %e %r%N%C-%z %T%N%c%N"
-country_name=""
-country_post=""
-country_ab2=" "
-country_ab3=" "
-country_car=""
-country_num=0
-country_isbn=""
-lang_name=""
-lang_ab=""
-lang_term=""
-lang_lib=""
+postal_fmt="%a%N%f%N%d%N%b%N%h %s %e %r%N%T, %S %z%N%c%N"
+country_name="United States"
+country_post="USA"
+country_ab2="US"
+country_ab3="USA"
+country_car="USA"
+country_num=840
+country_isbn="0"
+lang_name="English"
+lang_ab="en"
+lang_term="eng"
+lang_lib="eng"
address-codeset="UTF-8"
-tel_int_fmt="+%c %a %l"
-tel_dom_fmt=""
-int_select=""
-int_prefix=""
+tel_int_fmt="+%c (%a) %l"
+tel_dom_fmt="(%a) %l"
+int_select="11"
+int_prefix="1"
telephone-codeset="UTF-8"
-measurement=1
+measurement=2
measurement-codeset="UTF-8"
-title="C locale"
-source=""
-address=""
+title="English locale for the USA"
+source="Free Software Foundation, Inc."
+address="http://www.gnu.org/software/libc/"
contact=""
-email="aurel32@debian.org"
+email="bug-glibc-locales@gnu.org"
tel=""
fax=""
-language="C"
-territory=""
+language="American English"
+territory="United States"
audience=""
application=""
abbreviation=""
-revision="1.6"
-date="2016-08-08"
+revision="1.0"
+date="2000-06-24"
category="i18n:2012;UTF-8;;;;;;;;;;;"
identification-codeset="UTF-8"
ubuntu@minimal:~$

If you want to add the en_US.UTF-8 locale or any other, you can do so with

$ sudo apt install locales
$ locale-gen en_US.UTF-8
Generating locales (this might take a while)...
en_US.UTF-8... done
Generation complete.

You can then set the locale in this file,

ubuntu@minimal:~$ cat /etc/default/locale 
LANG=C.UTF-8
ubuntu@minimal:~$

Discussion

When you want to create containers or virtual machines, you can use either the standard Ubuntu images or the Minimal Ubuntu images. Here is their size difference,

$ lxc image info ubuntu:18.04
Fingerprint: b190d5ec0c537468465e7bd122fe127d9f3509e3a09fb699ac33b0c5d4fe050f
Size: 173.14MB
Architecture: x86_64
Public: yes


$ lxc image info ubuntu-minimal:18.04
Fingerprint: ca484a77810debc59dc59052f7ad6172daaf5d81551a5164f6c76f0ff7b15e90
Size: 92.76MB
Architecture: x86_64
Public: yes

These sizes are compressed sizes of the container images. When you create the container, it goes like this,

Container image      | Size (compressed container image)   | Size (container)------------------------------------------------------------------------------
ubuntu:18.04         | 173.14MB                            | 332MB                     |                                     |
ubuntu-minimal:18.04 |  92.76MB                            | 181MB

The Minimal Ubuntu images are about half in size of the Ubuntu images. Depending on your use-cases, you can very well go for the Minimal Ubuntu images to save space. If you want to somewhat complete container with most standard packages, you can get that with the Ubuntu images.

 

Permanent link to this article: https://blog.simos.info/a-closer-look-at-minimal-ubuntu-for-lxd/

1 comment

1 ping

    • Ron Kelley on October 16, 2018 at 02:56
    • Reply

    Great article. We have been using Ubuntu images for a while, and they always seem to be larger than necessary – especially for simply container images.

    Also, it seems the mirror location of “https://cloud-images.ubuntu.com/minimal/releases/” can be very slow at times (less than 1MB/sec here in the US). An alternative location to add is “mirrors.servercentral.com” like this:

    lxc remote add –protocol simplestreams ubuntu-minimal https://mirrors.servercentral.com/ubuntu-cloud-images/minimal/releases/

    Using this mirror, my download speed went from KB/sec to many > 20MB/sec.

  1. […] 参考、「A closer look at Minimal Ubuntu for LXD ? Mi blog lah!」 […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: