Application Container Systems (snap, flatpak)

Application containers are sandboxed packaging formats designed to distribute desktop and server applications across Linux distributions. They bundle the application with its dependencies, isolating it from the host system while providing controlled access to system resources.

Snap

Snap is Canonical's universal Linux packaging format. Snaps are compressed filesystem images (squashfs) that mount read-only at runtime, with writable overlays for user data.

Key Characteristics

  • Self-contained: Applications bundle all required libraries.
  • Sandboxed: Strict confinement using AppArmor profiles.
  • Automatic updates: Snapd checks for updates automatically.
  • Transactional: Updates are atomic; rollback on failure.
  • Cross-distro: Works on any distribution with snapd installed.

Managing Snaps

sudo snap install vlc            # Install a snap
sudo snap remove vlc             # Remove a snap
sudo snap refresh                # Update all snaps
snap list                        # List installed snaps
snap info vlc                    # Show snap details

Confinement

Snaps can run with different confinement levels:

  • Strict: Maximum sandboxing, limited system access. Most snaps use this.
  • Classic: Full system access, like traditional packages. Requires the --classic flag and store approval.

Example of classic snap:

sudo snap install code --classic

Flatpak

Flatpak is a framework for distributing desktop applications across Linux distributions. It focuses on graphical applications and desktop integration.

Key Characteristics

  • Runtime-based: Applications depend on runtimes (e.g., org.freedesktop.Platform, org.gnome.Platform) shared across apps.
  • Sandboxed: Uses Bubblewrap for sandboxing.
  • Portal-based: Accesses system resources (files, devices, network) through desktop portals, allowing user-controlled permissions.
  • Cross-distro: Applications run on any distribution with Flatpak installed.

Managing Flatpaks

flatpak install flathub org.videolan.VLC
flatpak uninstall org.videolan.VLC
flatpak update                  # Update all flatpaks
flatpak list                    # List installed flatpaks
flatpak run org.videolan.VLC    # Run a flatpak

Remotes

Flatpak packages are distributed through remotes. Flathub is the primary remote:

flatpak remote-add flathub https://flathub.org/repo/flathub.flatpakrepo

Comparison: Snap vs Flatpak

Feature Snap Flatpak
Primary Focus Desktop + Server Desktop
Sandboxing AppArmor Bubblewrap
Updates Automatic Manual or scheduled
Runtime Model Bundle everything Shared runtimes
Cross-distro Yes Yes
CLI Tools Supported Less common

When to Use Application Containers

Use application containers when:

  • The application is not available in distribution repositories.
  • You need the latest version of an application without waiting for distribution updates.
  • You want to distribute your application across multiple distributions.
  • You want to test software without affecting the host system.

Use system packages when:

  • The application is available in distribution repositories.
  • You need deep system integration (kernel modules, system services).
  • You want the distribution's security update mechanism.