A base snap is a special kind of snap that provides a run-time environment with a minimal set of libraries that are common to most applications. They’re transparent to users, but they need to be considered, and specified, when building a snap.
Bases are defined by adding the
base: keyword to a snap’s snapcraft.yaml followed by the base name.
There are currently two supported bases:
core18: the current standard base for snap building, based on Ubuntu 18.04 LTS
core: also known as core 16, and based on Ubuntu 16.04 LTS
For example, to specify core 18, use the following:
To specify core 16, use the following
The base snap mounts itself as the root filesystem within your snap such that when your application runs, the base’s library paths are searched directly after the paths for your specific snap.
When building your snap with no specified base, Snapcraft will operate in legacy mode. This is essentially a prior (2.43-era) version of Snapcraft, and will lose the functionalities and bug fixes introduced in the new version.
Building a base snap
While it is possible to build your own base snap, its publisher needs to take responsibility for its maintenance and updates. In particular:
- bases need to be built from stable packages
- ABI compatibility cannot broken (ie. never replace symbols or libraries, and be strict)
- security updates must be pro-active
Base snaps can be either bootable or non-bootable. The former needs to include systemd while the latter can be leaner.
base keyword on its own does not not take into account the creation of bases. Instead, with older versions of snapcraft, the
name keyword was arbitrarily used to determine the build environment:
name: core18 type: base # base: is not set elsewhere
The above example uses
name to specify the creation of an Ubuntu 18.04 (core18) based build environment.
But the above fails if a base has yet to be bootstrapped, or is otherwise unavailable. For example, the following will currently generate a `launch failed: Unable to find an image matching “core20” error:
name: core20 type: base # base: is not set elsewhere
In cases like the above, where the base has not yet been bootstrapped, the
build-base keyword should be used to explicitly define the base to use for the build environment.
To solve the above issue, for example, use the following:
name: core20 type: base build-base: core18 # base: is not set elsewhere