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: based on Ubuntu 16.04 LTS , not to be confused with
core16 is currently under development. With no current stable release, its beta and candidate releases are classed as experimental. As with
core18 (and distinct from
core), it’s built without bundling snapd and its associated tools. In both
core18, these are are instead provided by their associated snaps.
Older releases of
corewere occasionally referred to as core 16, but
core16are now two distinct packages.
For example, to specify core 18, use the following:
To specify core, 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.
core18 is the recommended base for the majority of snaps. It’s synonymous with the latest Long Term Support release of Ubuntu, Ubuntu 18.04 LTS, and it’s what the snapcraft init command includes when generating a new project’s template snapcraft.yaml.
But much like choosing a distribution base for a project or server, the best base for an application is dependent on an application’s requirements. If there are specific dependencies that cannot be easily met with
core is a valid and supported alternative.
Base support was added with the release of Snapcraft 3. As noted above, snaps created before this, and snaps not using the
base: keyword, can still be built but they cannot use specific new features. Instead, snaps built without bases inherit attributes from their respective build environments.
Snaps that don’t use bases can often migrate to one without too much difficulty. See Upgrading snapcraft for more details on potential differences.
While it is possible to build your own base snap, its publisher needs to take responsibility for its maintenance and updates. In particular:
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 “futurecore” error:
name: futurecore 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: futurecore type: base build-base: core18 # base: is not set elsewhere