Skip to content
Sample project that shows how to run Swift in Docker on Raspberry Pi and other ARM devices.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Swift on Balena – Hello, world! 👋

This is a sample project that shows how to run Swift on Raspberry Pi and other ARM devices using Docker images from Swift on Balena.

Getting Started

You can build and run this sample Swift Package Manager app in a Docker container by using Docker or by using BalenaCloud.

Using Docker

If you want to use Docker directly, the first step is to install Docker on your Raspberry Pi. You can do this by running a single command in a terminal on your Raspberry Pi.

$ curl -sSL | sh

Note: If you don't have a Raspberry Pi or other ARM device available, you can still follow the steps below using Docker Desktop on your Mac. Docker on macOS uses QEMU to emulate ARM architectures and can be used to build and run many ARM based Docker containers.

Once Docker is installed, clone this project to your Raspberry Pi and navigate to the balena-swift-hello-world directory.

$ git clone
$ cd balena-swift-hello-world

Build and tag a new Docker image using docker build.

Note: Depending on your device type, you may need to use a different Dockerfile. The command below is using Dockerfile.raspberrypi3 for Raspberry Pi 3 devices. Dockerfiles for other devices are included in this example project.

$ docker build -t balena-swift-hello-world -f Dockerfile.raspberrypi3 .

Now you can run the newly built Docker image using docker run.

$ docker run -it --rm balena-swift-hello-world

That's it! You just built and ran a Swift app in a Docker container on ARM! You should see the output below in your terminal.

Hello from Swift 👋

Using BalenaCloud

Balena makes it easy to develop, deploy, and run Docker containers on Raspberry Pi and other IoT devices.

If you don't already have an account setup, this tutorial is a great place to start.

Once you've setup a new application and provisioned a device, you can deploy this Swift project instead of the Rust program shown in the tutorial. The steps are almost the same!

When you're ready to deploy, clone this project and navigate to the balena-swift-hello-world directory.

$ git clone
$ cd balena-swift-hello-world

Add balena as a new git remote. You can find this in the top-right corner of your balena application page.

git remote add balena <USERNAME><USERNAME>/<APPNAME>.git

Now you can deploy this Swift project to all of the devices in your application with one command.

git push balena master

You'll know the Docker container has been built when you see a unicorn in your terminal! 🦄

Once your device(s) have downloaded and started the Docker container, you should see some logs from the Swift app.

Hello from Swift 👋

Congrats! You now have a Swift app running in a Docker container on a Raspberry Pi using balena.

Next Steps

Swift, Docker, and Balena

Community Projects

There is so much you can do with Swift on ARM. Try out some of these community projects to see what's possible.

Join the Swift on ARM community in the swift-arm Slack channel.

You can’t perform that action at this time.