Building the snap on Docker

Now that you have a snapcraft.yaml describing how to assemble your app and dependencies, you can build a snap.

You may already be using Docker for your build and test infrastructure. You can also use it to build snaps in these environments.

First, make sure you have Docker installed. You can test that Docker is correctly set up with:

docker run hello-world

If you don’t see the “Hello from Docker!” message, consult the Docker documentation for troubleshooting steps.

Next, pull down the latest snapcraft image:

docker pull snapcore/snapcraft

Return to the root directory of the project containing your snapcraft.yaml and run snapcraft:

docker run -v "$PWD":/build -w /build snapcore/snapcraft snapcraft

These options instruct Docker to map the current directory, your project root, to the /snapcraft_build directory inside the container, and then start the snapcraft command(the last command-line argument) from this same location inside the container.

If the snap build completes successfully, you will find a .snap file in the current directory. You can inspect its contents to ensure it contains all of your application’s assets:

unsquashfs -l *.snap

Next steps

Continue on to learn how to install, test, and publish your snap file.

Last updated a month ago. Help improve this document in the forum.