lxc / distrobuilder

System container image builder for LXC and Incus
https://linuxcontainers.org
Apache License 2.0
591 stars 170 forks source link

lxc with apple m3 pro chip #843

Closed 0xElmalky closed 6 months ago

0xElmalky commented 6 months ago
sudo $HOME/go/bin/distrobuilder build-lxd alpine.yaml -o image.release=3.18 -o image.architecture=x86_64  
INFO   [2024-05-10T18:07:44-04:00] Downloading source                           
INFO   [2024-05-10T18:07:45-04:00] Unpacking image                               file=/tmp/distrobuilder/alpinelinux-3.18-x86_64/alpine-minirootfs-3.18.6-x86_64.tar.gz
INFO   [2024-05-10T18:07:46-04:00] Managing repositories                        
INFO   [2024-05-10T18:07:46-04:00] Running hooks                                 trigger=post-unpack
INFO   [2024-05-10T18:07:46-04:00] Managing packages                            
Error: Failed to manage packages: Failed to refresh: fork/exec /sbin/apk: exec format error
ERROR  [2024-05-10T18:07:46-04:00] Failed running distrobuilder                  err="Failed to manage packages: Failed to refresh: fork/exec /sbin/apk: exec format error"
INFO   [2024-05-10T18:07:46-04:00] Removing cache directory 

what should I do with this error

stgraber commented 6 months ago

You're on an arm64 machine (M3) so you can't go and build x86_64 images, using image.architecture=aarch64 should work fine though.

0xElmalky commented 6 months ago

I want to make it with this arch as if I made it with aarm It is not going to work in the target server

stgraber commented 6 months ago

distrobuilder doesn't do cross architecture builds, you must run it on the target architecture.

0xElmalky commented 6 months ago

No do you know the lxc / lxd privilege scenario I am trying to do it

stgraber commented 6 months ago

To be clear, if you want to build an image to run on an x86_64 server, distrobuilder must be run on an x86_64 system. If you want to build an image to run on an aarch64 server, distrobuilder must be run on an aarch64 system.

All our own images are built in that way, we use Intel/AMD servers to build the x86_64 images, we use ARM 64bit servers to build aarch64 and we use ARM 32bit servers to build armhf.