9

I have seen this: what's the main difference between Docker and Snap?

I don't quite see the difference between snap and system containers.

  • VM has a separate Linux kernel and used fixed host resources using hypervisor.
  • Linux Container (system container, re-uses/share the kernel, and uses dynamic host resources.
  • Docker do not share the kernel, but a docker demon (early docker used Linux container) to allocate resources dynamically.

Do Snap fit between VM and Linux Containers, in the sense that it not only share the kernel but even more of the host system, without being a totally different installed OS using hypervisor?

Update: Snap is a sandbox with mediated access to the host system.

Artur Meinild
  • 26,018
Chris G.
  • 213
  • 1
    No, snaps has nothing to do with it. It's just a new way to package software. – ChanganAuto Jan 03 '22 at 13:26
  • 1
    The confusion is understandable. Docker is often misused as packaging -- applications that don't really need to be containerized, but the author wants to distribute them that way. And Snap packages sell their isolation and safety features, which seems similar to containerization at first glance, though the snap method is completely different. – user535733 Jan 03 '22 at 14:15

1 Answers1

14

I think this slide from Mark’s presentation on Container Camp 2016 explains a lot in a single image, and makes a lot of sense to me:

enter image description here

Video link: Why we need a different container purely for apps - Mark Shuttleworth (Canonical) - YouTube

To sum it up in short:

  • LXC/LXD are “machine containers” with a persistent filesystem that works like a VM
  • Docker are “process containers” with an overlay filesystem over a static image (with options for persistent storage)
  • Snaps are “application containers” that directly extends functionality of the underlying host

My personal experience:

  • I mostly use Docker for all the different web services on my home network (UniFi, Grafana/Prometheus, Bookstack, Nextcloud, Syncthing, Transmission, Proxy Manager, Iperf3 etc.), since Docker is especially well suited for isolating data and exposing ports for different services.

  • If I would ever need “VM” like functionality (where I needed to install custom packages that would persist in the container), I would take a look at LXC/LXD.

  • I have mixed feelings about snaps, and I think that depends entirely on your usecase. For those apps that are officially distributed as snaps, they might be worth it (for instance LXD or Multipass, which are both official Canonical snaps). 3rd party snaps can be of mixed quality, to say the least.

Artur Meinild
  • 26,018