Dockerfile for Ubuntu 22?

Hi, I’m new to Dockerfile and might have some basic questions—please correct me if I’m wrong.

I previously used Docker to create Ubuntu 18 images for our Circle CI builds. I now upgrading to Ubuntu 22.04, but I’ve encountered a hurdle. After I built my images through Dockerfile, During the Linux build process in Circle CI, I received an error stating, “LXD is required, but not installed.” but It appears that LXD cannot be installed directly within Docker.

  1. How should I approach installing LXD in our build environment? Should I include the LXD installation in the config.yml,, or directly in the Dockerfile?
  2. is there a way to avoid this error message? if I don’t think I will be using LXD.

Additionally, if anyone has a template or example that could guide me, it would be greatly appreciated.

Hi Ami, can you describe a bit more the role that Snapcraft plays in your case? Are you running it inside the Ubuntu 18 container created from the Docker image?

Hi @tigarmo,

I’ve built a new Docker image using ubuntu:jammy, which includes everything I need, such as Snapcraft, core22, Node.js, and more.

I’m running Snapcraft (previously on core 18, now core 22) in the Linux build process in Circle CI. My Snapcraft has now been updated to core 22 without a extension, and all other details remain the same as with the previous core 18.

I think the main issue is that after upgrading to core 22 on Snapcraft, I encountered an issue stating “LXD is required, but not installed” when trying to build my Linux through Circle CI.

The problem is either from Circle CI? or maybe my docker? or maybe some settings I can change from file.

I see. I believe for core22 Snapcraft does default to using lxd instances to build, but you should be able to get around that by setting SNAPCRAFT_BUILD_ENVIRONMENT=host on your image.

Thanks @tigarmo. I think SNAPCRAFT_BUILD_ENVIRONMENT=host helped when I added it in my Dockerfile. At least the build started running. One more follow-up question: after adding the SNAPCRAFT_BUILD_ENVIRONMENT, I got another error:

`Failed with exit code: 1
Error: Initializing parts lifecycle
Installing build-packages
The following snaps are required but not installed, as the application is running inside a Docker or Podman container: core22.
Please ensure the environment is properly set up before continuing.
Ignore this message if the appropriate measures have already been taken.
Pulling depends
Fetching stage-packages
Failed to refresh package list: failed to run apt update.`

I think it’s claiming that it can’t find core 22 in my Dockerfile, but I’m using FROM ubuntu:jammy , and I’m also getting core 22 by using the URL below:

curl -L $(curl -H 'X-Ubuntu-Series: 16' '' | jq '.download_url' -r) --output core22.snap && \ mkdir -p /snap/core22 && unsquashfs -d /snap/core22/current core22.snap && rm core22.snap &&

(I came up with this link because the lastest similar link was for core 20)

In my Snapcraft file, I’m also using base:core22 as well.

To provide more information, here’s my snap info in the container:

snap version 
snap    2.61.3+22.04 
snapd   unavailable 
series  - 
snapcraft --version 
snapcraft 8.2.3`

Sorry I just currently have no idea where to troubleshoot this issue, any idea would be appreciated! Thank you!

seems to be need to run with sudo or something similar (root privileges)