Unable to install snapcraft on ubuntu:focal


I just updated our build agent (based on docker) from ubuntu:bionic to ubuntu:focal. I am installing snapcraft via a RUN apt-get install -y --no-install-recommends snapcraft to be able to upload snaps via build pipeline. Since update to focal, the installation stops with following error:

Selecting previously unselected package snapcraft.
(Reading database ... 29548 files and directories currently installed.)
Preparing to unpack .../000-snapcraft_3.0ubuntu1.1_all.deb ...
=> Installing the Snapcraft snap
==> Checking connectivity with the snap store
===> Unable to contact the store, trying every minute for the next 30 minutes


  1. Is it possible to install snapcraft on ubuntu:focal docker container?
  2. Is there an alternative? I just need to snapcraft push or snapcraft release within my container.

This appears to be the problem: internet connectivity with the snap store.

Clearly, if your container cannot contact the store, then neither snapcraft push or snapcraft release would work anyway.

The container has unlimited internet access. apt-get update and all other commands are working well.

To clarify: docker run -it --rm ubuntu:bionic bash -c "apt-get update && apt-get install snapcraft is working

and docker run -it --rm ubuntu:focal bash -c "apt-get update && apt-get install snapcraft does not work.

the snapcraft deb has long been abandoned (it is at 3.x while snapcraft itself is about to move to 7.x), what alan meant is that the two commands will probably not work as expected even if you get the deb installed …

Ah OK. Because I need snapcraft for releases I came up with following solution:

FROM ubuntu:focal
COPY --from=snapcore/snapcraft:stable /snap /snap 
ENV PATH="/snap/bin:$PATH"
ENV SNAP="/snap/snapcraft/current"
ENV SNAP_NAME="snapcraft"
ENV SNAP_ARCH="amd64"	

I copy the relevant snapcraft files from docker image instead of installing it via package manager.

It would be nice to have a compact CLI that is independent from the rest of the tooling. This solution requires 804MB to be able to publish snaps.

I wonder if this will really work well for you. Snapcraft needs to use lxd or multipass and at least lxd won’t really work insider docker.