Snapd in ubuntu:24.04 image doesn't start

hello,

previously while using a custom-docker image that was generated using the below Dockerfile iwas able to successfully use snapd/snap and install snaps in privileged container:

FROM ubuntu:22.04

RUN <<-EOT
	  apt-get update -y
    apt-get install -y --no-install-recommends ca-certificates snapd systemd init
    apt-get clean
    systemctl mask -- dev-hugepages.mount sys-fs-fuse-connections.mount
    rm -rf /var/lib/apt/lists/* /var/log/alternatives.log /var/log/apt/history.log /var/log/apt/term.log /var/log/dpkg.log
    rm -rf  /etc/machine-id /var/lib/dbus/machine-id
EOT

ENV container docker
STOPSIGNAL SIGRTMIN+3
ENTRYPOINT [ "/sbin/init" ]
CMD ["/bin/bash"]

and with the following command for privileged container named snappy:

docker container create --name snappy --privileged snap_image
docker container exec -it snappy /bin/bash

but now when itry to do the same with 24.04 tag it fails with cannot communicate with server, upon further checking via systemctl status snapd the below is reported:

β—‹ snapd.service - Snap Daemon
     Loaded: loaded (/usr/lib/systemd/system/snapd.service; enabled; preset: enabled)
     Active: inactive (dead)
TriggeredBy: β—‹ snapd.socket

icant even manually start it with: systemctl start snapd as it hangs on 24.04

Did something change between the releases or was idoing this wrong from the beginning :sweat_smile:

Hi,

I suggest taking a look at this solution, which achieves your goal, but also works when using ubuntu 24.04 tag as the base image.

Cheers, Just

hi @jocado

thanks for the suggestion but im not looking for having snapcraft image but nonetheless will use it as reference.

for the time-being imade it work by removing mount mask and machine-id commands from Dockerfile, the resultant image works

FROM ubuntu:24.04

RUN <<-EOT
    apt-get update -y
    apt-get install -y --no-install-recommends ca-certificates snapd systemd init
    apt-get clean
    rm -rf /var/lib/apt/lists/* /var/log/alternatives.log /var/log/apt/history.log /var/log/apt/term.log /var/log/dpkg.log
EOT

ENV container docker
STOPSIGNAL SIGRTMIN+3
ENTRYPOINT [ "/sbin/init" ]
CMD ["/bin/bash"]

but not sure if it is good idea to have same machine-id over all containers :thinking:

Sorry, yes I was assuming snapcraft, but as you indicate it’s still a good reference for using of snapd in a docker container :+1:

Glad you got it working in the meantime though!

Cheers, Just

1 Like