indigo-dc / udocker

A basic user tool to execute simple docker containers in batch or interactive systems without root privileges.
https://indigo-dc.github.io/udocker/
Apache License 2.0
1.32k stars 133 forks source link

Udocker pulls image for the wrong processor architecture #388

Closed ddscentral closed 10 months ago

ddscentral commented 1 year ago

udocker pull pulls image for the wrong processor architecture. When running under arm64, amd64 (aka. x86-64) image is pulled, even though a native arm64 image is available for that container. Correct behavior should match that of "docker pull" command: try to pull image for the host machine architecture first and if it isn't available, display a warning and pull image for a different architecture, usually amd64.

Platform: Android (Termux)

dhanar10 commented 1 year ago

I am encountering the same problem trying to use udocker in termux. I tried to figure out what's wrong by running udocker -D pull hello-world. Looking at the debug output, it seems like udocker is fetching manifest v2 version 1 instead of version 2. I think this is probably the problem because according to docker docs I read, it looks like multi arch requires manifest v2 version 2. But CMIIW.

Edit: For clarity, my udocker is V1.3.8

ddscentral commented 1 year ago

I've noticed the manifest issue as well. Did some digging in the code but could not find a reason why manifest v1 is pulled. I work-arounded the wrong architecture issue by adding support for pulling images by their SHA256 hashes (Docker syntax: docker pull imagename@sha256:). This allows me to force udocker to request a specific image instead of a tag. Not the most convenient way, but it does the job. I can upload my patched version of udocker if anyone needs it (the code would require some cleaning-up for a proper PR).

dhanar10 commented 1 year ago

@ddscentral Nice! I am interested with your patched version of udocker. I will be thankful if you can share it somewhere.

ddscentral commented 1 year ago

Link: udocker-1.3.7-patched-DDSC.tar.gz

Changes:

I made this fork for my own uses and will not provide support for it. Code cleanup is welcome.

dhanar10 commented 1 year ago

@ddscentral I have a couple of questions about your fork.

  1. You added qemu multiarch stuff, so the use case is to run x86 image on arm, am i understanding it correctly?

image

  1. Why did you add proot link2symlink here? What problem you are trying to solve here?

image

ddscentral commented 1 year ago
  1. Yes, this allows to run images made for a different processor architecture (eg. x86 on ARM). This works similarly to https://github.com/tonistiigi/binfmt but in user mode and without requiring binfmt support.
  2. Sorry, my comment probably isn't the clearest. Proot with link2symlink is required to workaround permission issues when extracting Docker images which contain hardlinks. This option converts them to symlinks. Without this, you would require root privileges to extract images which contain hardlinks.
ddscentral commented 1 year ago

Another note: when running udocker under Termux, you will need to replace the "proot" binary installed by Udocker with Termux version as the stock one will not work on Android.

jorge-lip commented 1 year ago

This issue should be fixed in release 1.3.9.

mariojmdavid commented 10 months ago

release 1.3.11 created