Using docker for clean builds of classic snaps

VanCutsem, Geoffroy geoffroy.vancutsem at intel.com
Mon Feb 6 08:16:17 UTC 2017



> -----Original Message-----
> From: snapcraft-bounces at lists.snapcraft.io [mailto:snapcraft-
> bounces at lists.snapcraft.io] On Behalf Of Joseph Rushton Wakeling
> Sent: Sunday, February 5, 2017 11:52 PM
> To: snapcraft at lists.snapcraft.io
> Subject: Re: Using docker for clean builds of classic snaps
> 
> On 05/02/17 19:33, Loïc Minier wrote:
> > I dont think "snapd" is in the "ubuntu" Docker image which is trimmed
> > down a bit
> 
> Yes, I gathered that much, which is why my own Dockerfile attempt ensured
> that snapd would be installed with this line:
> 
>      RUN apt-get --assume-yes install snapd snapcraft
> 
> ... but as you say:
> 
> > it's also likely that snapd/snaps would hit some technical issues when
> > inside Docker. (This might be worth researching/debugging if you're
> > tempted.)
> 
> It looks to me like the snapd daemon doesn't actually run inside the
> container.
> If I try something simple like checking the version of snapd installed, then I
> get this output:
> 
> $ sudo docker run -v $PWD:$PWD -w $PWD 592f87a670d0 snap --version
> 2017/02/05 22:43:59.308309 main.go:220: WARNING: cannot create syslog
> logger
> snap    2.21
> snapd   unavailable
> series  -
> 
> ... so it's clearly installed in my custom image, but not started.
> 
> If I _do_ try starting it as part of the command to run in the container, I get
> the following:
> 
> $ sudo docker run -v $PWD:$PWD -w $PWD 592f87a670d0 systemctl enable -
> -now snapd.socket && snap install core && snapcraft clean && snapcraft
> error: access denied (try with sudo)
> 
> Trying `sudo` (as in `sudo systemctl enable ...`) doesn't seem to make any
> difference.
> 
> Any thoughts on what else I could try?  I'm happy to keep exploring myself
> but Docker and sockets aren't really my area of expertise.

I ran into something similar when trying to build a Docker image that would start services via systemd service files. It turned out that systemd does not run out-of-the-box in Docker containers (this was the best blog post I had found on the topic: https://rhatdan.wordpress.com/2014/04/30/running-systemd-within-a-docker-container/, and a seemingly working mechanism, for Ubuntu 15.xx here: https://github.com/dockerimages/docker-systemd).

I actually did not go down that path as I found it easier for me to simply start my daemons/services outside of systemd, from a simple script invoked by CMD in my Dockerfile. This may just work and be sufficient for you.

Geoffroy


> 
> I would imagine, though, that the kinds of issues I'm running into with
> Docker are fundamentally the same issues that make it hard for classic snaps
> to support `snapcraft cleanbuild` using lxd ... ?
> 
> Thanks & best wishes,
> 
>      -- Joe
> 
> --
> Snapcraft mailing list
> Snapcraft at lists.snapcraft.io
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/snapcraft




More information about the Snapcraft mailing list