Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dockerfile, how install snap, snapd: unrecognized service

well I got some problem with my Dockerfile, in fact I try to install snapd on Debian and Ubuntu in almost all version.

When I try to launch a command I got this error

error: cannot communicate with server: Post http://localhost/v2/snaps/rocketchat-server: dial unix /run/snapd.socket: connect: no such file or directory

So I tried to see if the service is enabled, and there is no service called snapd, even if I try to start with systemctl systemctl start snapd, I have an error

Failed to connect to bus: No such file or directory

so I installed dbus, and when I try again now I have this error

Failed to start snapd.service: Launch helper exited with unknown return code 1

I tried to start the service with service or journalctl and it shows

snapd: unrecognized service

When I list all my services I have this

 [ - ]  apparmor

 [ - ]  bootmisc.sh

 [ - ]  checkfs.sh

 [ - ]  checkroot-bootclean.sh

 [ - ]  checkroot.sh

 [ + ]  dbus

 [ - ]  hostname.sh

 [ ? ]  hwclock.sh

 [ - ]  killprocs

 [ - ]  mountall-bootclean.sh

 [ - ]  mountall.sh

 [ - ]  mountdevsubfs.sh

 [ - ]  mountkernfs.sh

 [ - ]  mountnfs-bootclean.sh

 [ - ]  mountnfs.sh

 [ ? ]  ondemand

 [ - ]  procps

 [ - ]  rc.local

 [ - ]  sendsigs

 [ + ]  udev

 [ - ]  umountfs

 [ - ]  umountnfs.sh

[ - ]  umountroot

 [ - ]  urandom

FROM ubuntu:16.04

RUN apt-get update && apt-get -y upgrade &&\
    apt-get install -y snap snapd

RUN snap install rocketchat-server
#"error: cannot communicate with server: Post #http://localhost/v2/snaps/rocketchat-server: dial unix #/run/snapd.socket: connect: no such file or directory"

RUN snap --version
#snap    2.40
#snapd   unavailable
#series  -

EXPOSE 3000

ENTRYPOINT Server is running .... && tail -f /dev/null

I know that with docker playing with service is not good but I don't know how can I improve my Dockerfile, I begin with rocketchat doc debian, then ubuntu, then snap (because its easier), and with all of them I got this error.

like image 665
Sinay Avatar asked Oct 14 '19 23:10

Sinay


People also ask

Can I install Docker with snap?

Enable snaps on Ubuntu and install docker Snaps are applications packaged with all their dependencies to run on all popular Linux distributions from a single build. They update automatically and roll back gracefully. Snaps are discoverable and installable from the Snap Store, an app store with an audience of millions.


2 Answers

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.

like image 84
nicht-vergessen Avatar answered Oct 08 '22 21:10

nicht-vergessen


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)

like image 2
Joseph Lust Avatar answered Oct 08 '22 23:10

Joseph Lust