Dockerfile, how install snap, snapd: unrecognized service Dockerfile, how install snap, snapd: unrecognized service docker docker

Dockerfile, how install snap, snapd: unrecognized service


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.


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)


I had a similar issue on GCP's dedicated os for containers.This is how it worked for me (based on the Joseph Lust's reply):

Before you start:

  • Make sure the DNS is pointing to your VM external IP
  • make sure that anyone can access port 80
  • stop the container with your app if it is using port 80 (certbot container will create a http server on port 80)

Run the certbot container:

sudo docker run -it --rm --name certbot \            -v "/etc/letsencrypt:/etc/letsencrypt" \            -v "/var/lib/letsencrypt:/var/lib/letsencrypt" \            -p 80:80 \            certbot/certbot certonly

Select option 1 and then input your domain. (Would be nice to find a way to automate this ... )

Start your container with mounted volumes for :

        -v "/etc/letsencrypt:/etc/letsencrypt"         -v "/var/lib/letsencrypt:/var/lib/letsencrypt"