---
title: Learn snapcraft by example – multi-app client-server snap
description: Over the past few months, we published a number of articles showing how
  to snap desktop applications written in different languages – Rust, Java, C/C++,
  and others. In each one of these zero-to-hero guides, we went through a representative
  snapcraft.yaml file and highlighted the specific bits and pieces developers need
  to successfully bui […]
url: https://canonical.com/blog/learn-snapcraft-by-example-multi-app-client-server-snap?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Igor Ljubuncic](https://canonical.com/blog/author/igorljubuncic "More about Igor Ljubuncic")

27 March 2020

# Learn snapcraft by example – multi-app client-server snap

[alias](https://canonical.com/blog/tag/alias)
[client-server model](https://canonical.com/blog/tag/client-server-model)
[network](https://canonical.com/blog/tag/network)
[snapcraft](https://canonical.com/blog/tag/snapcraft)
[snapcraft.io](https://canonical.com/blog/tag/snapcraft-io)

---

Share the article

Over the past few months, we published a number of articles showing how to snap desktop applications written in different languages – [Rust](https://snapcraft.io/blog/building-a-rust-snap-by-example), [Java](https://snapcraft.io/blog/building-a-java-snap-by-example), [C/C++](https://snapcraft.io/blog/building-a-c-snap-by-example), and others. In each one of these zero-to-hero guides, we went through a representative snapcraft.yaml file and highlighted the specific bits and pieces developers need to successfully build a snap.

Today, we want to diverge from this journey and focus on the server side of things. We will give you an overview of a snapcraft.yaml with two interesting components: a) it will have more than one application; typically, snaps come with one application inside b) it will have a simple background service, to which other applications can connect. Let’s have a look.

# The basics

Here’s the relevant part of the snapcraft.yaml file:

```
apps:
  borg:
    command: bin/borg
    daemon: simple
    restart-condition: on-abnormal
    plugs:
      - home
      - network
      - network-bind
  locutus:
    command: bin/locutus
    plugs:
      - home
      - network
```

## What do we have here?

First, we declare the server part of the bundle – an application named borg. It is a simple daemon, and the restart condition will be “on-abnormal” – the [service states](https://snapcraft.io/docs/services-and-daemons) are based on values returned from systemd.

Second, for the service to work, it needs to be able to bind to network ports, which is why we’re defining the *network-bind* interface. Please note that if your application needs to bind to a privileged port, you will need sudo to be able to make it run correctly. The use of snaps does not change the underlying security requirements.

We also define access to *home* (so that the service can read a configuration file, for instance), and *network*, so it can communicate over the network. This is necessary in addition to the bind declaration, unless your service is designed to only run and listen on localhost.

In the second part, we declare the client part of the bundle – an application that only needs access to the home directory (configuration files, certificates, etc.), and network. This way, you can run the component applications of this snap on various systems, in a classic client-server model.

## How to invoke a multi-app snap?

The one question you may have is – with multiple apps inside a snap, how does the user run them? When the app name matches the snap name, e.g.: igor, you only need to run “igor” or “/snap/bin/igor”. Here, the invocation is slightly different. Let’s say the snap is called “picard”. In this case, for the server application, you would run:

```
picard.borg
```

Similarly, for the client application:

```
picard.locutus
```

Users can manually create [aliases](https://snapcraft.io/docs/commands-and-aliases) to work around this. Similarly, developers can request automatic aliases for their software from the Snap Store team, in cases where there is no obvious namespace clash. This can lead to a smoother, more streamlined user experience. In this example, borg will be mapped to picard.borg, and locutus will be mapped to picard.locutus.

# Summary

We hope today’s guide sheds clarity on how to make somewhat more elaborate use cases with snaps, including multi-apps and client-server scenarios. Of course, creating the snapcraft.yaml is only part of the work, you also need to make sure that your software parts can communicate with one another, and do their job correctly. However, at least you have the snapcraft side of things covered.

If you have any comments, or perhaps requests on future articles that would help you snap your application (or a complex service), please join our [forum](https://forum.snapcraft.io/) for a discussion.

No Star Trek TNG references were aliased in the creation of this article.

Photo by [Marlon Corona](https://unsplash.com/@marlon10?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText).

[Get in touch

Interested in running Ubuntu in your organization?](https://ubuntu.com/about/contact-us/form)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### Snapcraft 8.0 and the respectable end of core18](https://canonical.com/blog/snapcraft-8-0-and-the-respectable-end-of-core18)

‘E’s not pinin’! ‘E’s passed on! This base is no more! He has ceased to be! ‘E’s expired and gone to meet ‘is maker! ‘E’s a stiff! Bereft of life, ‘e rests in peace! If you...

[Igor Ljubuncic](https://canonical.com/blog/author/igorljubuncic)

16 June 2023

[### What is RDMA over Converged Ethernet (RoCE)?](https://canonical.com/blog/what-is-rdma-over-converged-ethernet-roce)

Previous articles walked through RDMA (Remote Direct Memory Access) as a programming model and InfiniBand as the fabric that was built around it. Both led to the same...

[Benjamin Ryzman](https://canonical.com/blog/author/benjaminryzman)

9 June 2026

[### What is InfiniBand?](https://canonical.com/blog/what-is-infiniband)

When distributed workloads stall because nodes cannot exchange small messages quickly and consistently, the network is the limiting factor. How do you solve that problem?...

[Benjamin Ryzman](https://canonical.com/blog/author/benjaminryzman)

2 June 2026

[### TurtleBot3 OpenCR firmware update from a snap](https://canonical.com/blog/turtlebot3-opencr-firmware-update-from-a-snap)

The TurtleBot3 robot is a standard platform robot in the ROS community, and it’s a reference that Canonical knows well, since we’ve used it in our tutorials. As a matter of...

[gbeuzeboc](https://canonical.com/blog/author/gbeuzeboc)

25 September 2024
