Dockerfile, how install snap, snapd: unrecognized service

I ran into this problem too, but was able to use the EFF's prebuilt Certbot images on DockerHub

FROM certbot/certbot:latest (see all tags)


first of all, you don't want to install the "snap" package, as it is not related to "snapd". Secondly, myself stumbled across this issue of installing snapd within a docker container: TLDR; Running snapd that way is currently not supported.

But that question has been asked already at the snapcraft forums. One of snapd's dependencies is systemd and the snapd-service isn't properly initialized without a reboot or relogin. That is the required procedure according to the documentation across all distributions, but obviously isn't an option within docker.

At least this open question replicates your question most: unable-to-install-snapcraft-snap-in-docker-image-ubuntu-19-10

And Evan at the snapcraft forum here posted an approach, that I couldn't get to work either.

The only approach that might work is similar to running docker inside of docker, i.e.:

  • install snapd on the docker host
  • mount the snapd-socket at runtime into the container that has snapd installed.

But same warnings/side-effects apply as they do to running docker-in-docker.