iximiuz / docker-to-linux

Make bootable Linux disk image (ab)using Docker
https://iximiuz.com/en/posts/from-docker-container-to-bootable-linux-disk-image/
669 stars 93 forks source link

Error with extlinux #10

Closed xavigonzalvo closed 3 years ago

xavigonzalvo commented 3 years ago

Observing the following issue when building the container:

#6 0.611 E: Package 'extlinux' has no installation candidate
iximiuz commented 3 years ago

Hi Xavi! What is your system setup and what distr have you tried building? I just tried all currently supported options (debian, ubuntu, and alpine) and they worked well for me.

From my host machine:

$ uname -a
Linux bpf-debian11-5-10 5.10.0-6-amd64 #1 SMP Debian 5.10.28-1 (2021-04-09) x86_64 GNU/Linux

$ docker version
Client: Docker Engine - Community
 Version:           20.10.6
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        370c289
 Built:             Fri Apr  9 22:46:58 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:45:08 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
xavigonzalvo commented 3 years ago

I'm working on a M1 Macbook air but I've used docker for a while with no issues.

$ uname -a
Darwin Javiers-Air 20.1.0 Darwin Kernel Version 20.1.0: Sat Oct 31 00:07:10 PDT 2020; root:xnu-7195.50.7~2/RELEASE_ARM64_T8101 arm64
$ docker version
 Client: Docker Engine - Community
 Cloud integration: 1.0.12
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:13:00 2021
 OS/Arch:           darwin/amd64 (rosetta)
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:16:48 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
xavigonzalvo commented 3 years ago

I think it's a matter of the architecture taken for the debian container. In case of M1 it'll take aarch64. It works if Dockerfile explicitly specifies amd64.

FROM amd64/debian:stretch
iximiuz commented 3 years ago

Good point! When I was creating this project, M1 wasn't really a thing. Also, I should probably have stated it explicitly in the README file, but I never tried running this directly on macOS. Not sure if it'll work. A quick check on my old-ish MBP returns losetup: command not found from the Makefile. Normally, I just run it from a VirtualBox machine instead. However, in the case of M1, that's unlikely an option... Probably adding ARM support will require some extra work.

xavigonzalvo commented 3 years ago

Yes, as you say, the losetup is missing in Mac Os. However, not sure why the loopback needs to be passed to the container but I can confirm that I produced the final image and it starts a system in qemu.

Changes:

The final image runs on qemu. A couple of issues, I don't know if that's related to my changes:

iximiuz commented 3 years ago

I merged a bunch of changes addressing your findings. Now it works on both Linux and macOS for me. But I cannot check the M1 chip.

Regarding the read-only fs and missing networking - these are known limitations. It shouldn't be too hard to make both things work, however, I'm out of capacity at the moment.

xavigonzalvo commented 3 years ago

That's great! I can confirm that everything works fine.

This is really cool stuff you have here.

iximiuz commented 3 years ago

Yay! Thanks for validating!