snapd
overview for everyone
snapd is the daemon that installs, runs and confines snaps; one snap install passes through most districts of this map, and the rest serve Ubuntu Core, the desktop, developers and administrators.
On the map: the whole city
01 What snapd is
The snap command asks snapd over a local socket. snapd fetches the snap from the store, verifies its assertions, mounts it read-only, sets up its security profiles and connections, and records each step as a task in its state.
You type snap install photo-editor. The snap command doesn't do the work itself. It sends a request over a local socket to snapd, the daemon that installs, runs and confines snaps. snapd asks the store, downloads the file and checks its signed assertions. It mounts the file read only, writes the security profiles and connects the interfaces the rules allow. Every step is a task recorded in its state, so if snapd restarts halfway, it carries on. And when you start the app, snap-confine puts it in its sandbox.
02 One install crosses the map
Getting snaps, assertions, policy, interfaces and confinement, sandbox internals, running snaps, hooks and snapctl: one snap install touches each district.
That one install crosses most of this map. Getting snaps covers the store, channels and the snap file itself. Assertions covers the signatures snapd checks. Policy decides whether the snap may install and which of its plugs connect by themselves. Interfaces and confinement turn connections into a sandbox, and sandbox internals show how it's built. Running snaps covers the change of tasks that does all of this, and then services, refresh, configuration and snapshots. Along the way the snap's own hooks run, and they talk back to snapd through snapctl.
03 How to use the map
Go in any order. The perspective picker chooses the scenes; Everyone shows all of them. Each deck ends with roads onward, and flags mark the topics you have opened.
You don't have to go in order. Pick a perspective at the top: snap user, app developer, Ubuntu Core developer, snapd developer or administrator. Each deck then shows the scenes written for you, and Everyone shows them all. Every deck ends with roads that lead on: deeper into the implementation, out to what you see at the command line, or sideways to a neighbour. The interface families and a few other decks list every entry below the slides. And a flag on the map marks each topic you've opened, so you can see where you've been.
04 Where to go from here
Roads: Ubuntu Core, encryption, desktop, developing snaps, administration, inside snapd, tools, and why snaps.
Beyond the install path, some districts serve one kind of job. Ubuntu Core has four: boot, bootloaders, install and recovery, and full disk encryption, for devices built entirely from snaps. Desktop covers snaps in your session: prompts, desktop files and portals. Developing snaps covers trying, packing, layouts and debugging. Administration covers aliases, parallel installs, quota groups, users and warnings. Inside snapd covers the REST API, restarts, the state and images. Tools covers snap debug. And if you're new, why snaps is the place to start.
Read more
Districts of the map
| District | Start with | What it covers |
|---|---|---|
| Start here | Why snaps | the problems snaps solve, and this overview |
| Getting snaps | Store | the store, channels, the snap file, brand stores, epochs |
| Interfaces and confinement | Interfaces | plugs, slots, connections, the sandbox, classic confinement |
| Interface families | Classification | every interface, grouped by what it touches |
| Policy | Interface policy | the base declaration, snap-declaration rules and how one rule decides |
| Assertions | Assertions | signed statements: identity, snaps, devices, validation sets |
| Running snaps | Overlord | changes and tasks, refresh, services, snapshots, configuration, removal |
| Hooks | Hooks | code snapd runs inside a snap at fixed moments |
| snapctl | snapctl | the command a snap uses to talk to snapd |
| Ubuntu Core: boot, bootloaders, install and recovery | Ubuntu Core | modes, boot path, GRUB and the other bootloaders, seeding, recovery systems, the model |
| Ubuntu Core: full disk encryption | Encryption | sealing, unlocking, keys, devices without a TPM |
| Administration | Aliases | aliases, parallel installs, quota groups, users, warnings, components |
| Desktop | AppArmor prompting | prompts, desktop files, the session agent, portals and themes |
| Developing snaps | Try and pack | snap try and pack, layouts, running and debugging, system usernames |
| Sandbox internals | Mount namespace | the mount namespace, snap-update-ns, the system key, hotplug |
| Inside snapd | REST API | sockets and access, restarts and re-exec, state patches, images |
| Tools | snap debug | commands for looking inside snapd |
for app developers for Ubuntu Core developers for snapd developers for administrators
The daemon and its clients
| Item | Value |
|---|---|
| Daemon | snapd, started by systemd from snapd.service and snapd.socket |
Socket for the snap command | /run/snapd.socket |
| Socket for snaps (snapctl) | /run/snapd-snap.socket |
| State | /var/lib/snapd/state.json |
| Snap files | /var/lib/snapd/snaps/<name>_<revision>.snap, mounted under /snap/<name>/<revision> |
Further reading
- System architecture: snapd, the store and the kernel security modules in one diagram.
- Get started: the commands a new user meets first.
- Glossary: the terms used across the snap documentation.
- Snapd REST API: the API the
snapcommand uses.
Roads from here
START HERE
- Why snaps — the three problems that shaped snapd
GETTING SNAPS
- The store — where snaps come from
INTERFACES AND CONFINEMENT
- Interfaces — interfaces are the part every snap touches
- Confinement — what confinement actually is
RUNNING SNAPS
- The overlord — every operation is a change made of tasks
SNAPCTL · the snap's API into snapd
- snapctl: how it works — how a snap talks back to snapd
ASSERTIONS · signed statements snapd trusts
- Assertions: how they work — the signatures snapd checks
HOOKS · code snapd runs inside a snap
- Hooks: how they work — the snap's own code that snapd runs
POLICY · who may install and connect what
- Interface policy: the questions snapd asks — who decides what may install and connect
TOOLS
- snap debug: tools for looking inside — tools for looking inside
UBUNTU CORE · boot
- Ubuntu Core: how a device boots and recovers — Ubuntu Core and its boot
UBUNTU CORE · full disk encryption
- What is encrypted and who decides — full disk encryption on Ubuntu Core
ADMINISTRATION · managing a system of snaps
- Aliases — administration of a system of snaps
DESKTOP · snaps in a user session
- AppArmor prompting — snaps on the desktop
DEVELOPING SNAPS · try, pack, run, debug
- Trying and packing a snap — developing a snap
INSIDE SNAPD · the daemon itself
- The snapd REST API — inside the daemon