Running snapcraft with podman


#1

podman allows to run Docker (and non-Docker) containers without any demons or root privileges. That means without sudo or asking your administrator to add you to docker group. It creates new user process that is isolated by Linux kernel itself.

On Fedora you can install podman with standard way dnf install podman, on Ubuntu there is an initiative to pack podman as a snap.

podman requires container image to run. Official Docker images are fine.

✗ podman run snapcore/snapcraft:beta snapcraft version

Locale not set! Snapcraft will temporarily use C.UTF-8
snapcraft, version 3.0.1

podman command line is fully compatible with Docker. To make something useful out if it, cd into directory with you project and run snapcraft image with current directory ($PWD) mounted as /src inside.

✗ podman run -v $PWD:/src:Z -w /src snapcore/snapcraft:beta snapcraft

:Z is needed for write access with SELinux on Fedora. -w changes current working directory inside container.

To be continued… (why you’d want to run snapcraft from container - “all your base” or “heavy (virtual) machines vs lightweight container builds”).


#2

Packing podman itself into a snap was picked up by upstream, but then it’s gone. Waiting for response from libpod project.

Official Docker images of snapcraft that could be run with podman as of April 2019.

✗ podman run snapcore/snapcraft snapcraft --version
snapcraft, version 2.43.1
✗ podman run snapcore/snapcraft:latest snapcraft --version      
snapcraft, version 2.43.1
✗ podman run snapcore/snapcraft:stable snapcraft --version
Locale not set! Snapcraft will temporarily use C.UTF-8
snapcraft, version 2.43.1
✗ podman run snapcore/snapcraft:beta snapcraft --version
Locale not set! Snapcraft will temporarily use C.UTF-8
snapcraft, version '3.3'
✗ podman run snapcore/snapcraft:candidate snapcraft --version
Locale not set! Snapcraft will temporarily use C.UTF-8
snapcraft, version '3.3'
✗ podman run snapcore/snapcraft:edge snapcraft --version
Locale not set! Snapcraft will temporarily use C.UTF-8
snapcraft, version 3.3+git1.g46e3d17

snapcraft:beta is the best choice for now.


#3

Use core18 to switch off snapcraft compatibility mode with 2.x version.

base: core18

Then use --destructive-mode flag added in 3.x to build snap inside docker container.

podman run -v $PWD:/src:Z -w /src snapcore/snapcraft:beta snapcraft --destructive-mode

Unfortunately, this doesn’t work.

✗ podman run -v $PWD:/src:Z -w /src snapcore/snapcraft:beta snapcraft --destructive-mode -d
Locale not set! Snapcraft will temporarily use C.UTF-8
Using 'snap/snapcraft.yaml': Project assets will be searched for from the 'snap' directory.
Failed to get information for snap 'core18': could not connect to 'http+unix://%2Frun%2Fsnapd.socket/v2/snaps/core18'.

#4

This will not work, we have quirks in place for docker to warn and not install. We do not have a general mechanism in place to ignore this.