Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show where to store images in the lima instance #235

Closed
wants to merge 1 commit into from

Conversation

afbjorklund
Copy link

@afbjorklund afbjorklund commented Dec 6, 2023

Description of the Pull Request (PR):

While it is possible to shell into the virtual machine, it is also possible to call apptainer.lima on the host.

This makes it easier to interact with the local files, and to copy the resulting SIF files to another location.

Currently this is not really showing the interaction from the host, since it is assumed to be "as normal".

Just details on where the images can be stored, in order to 1) be used in the guest 2) be used on the host

apptainer-storage

This fixes or addresses the following GitHub issues:


Unfortunately Sphinx doesn't like PS1, which makes the prompts somewhat confusing.

anders@ubuntu:~$ lima
anders@lima-apptainer:/home/anders$ 

But hopefully people can sort it out anyway? It's not so different from when using ssh.

anders@ubuntu:~$ ssh -F ~/.lima/apptainer/ssh.config lima-apptainer
anders@lima-apptainer:~$ 

Notes

  1. limactl shell is a command for ssh
  2. lima is a shell wrapper for limactl shell
  3. apptainer.lima is a shell wrapper for lima apptainer

So the end result is similar to running : ssh lima-apptainer apptainer, with variables.
The most useful one being APPTAINER_BINDPATH, for mounting /Users/$USER too.

In case you haven't seen Lima before, the "lima-apptainer" is a Linux Machine (LiMa)
Normally it is a VM running locally, but it could be a physical server or a cloud server.

@@ -216,6 +216,30 @@ supported by {Project}. To see a comparison of the {Project}
definition file with Dockerfile, please see: :ref:`this section
<sec:deffile-vs-dockerfile>`.

.. note::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is talking about accessing files, I think this would be better at the end of the Working with files section. It's only there that the concept of mounting home directories is introduced.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also put a label here and refer to it from the admin docs, if this is going to be the only place where the user interaction with Lima is going to be documented. I'm not completely convinced that it shouldn't have its own separate page in the user doc, but I'm ok with this for now at least.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the page should work as-is, it is only the ones that reference a file in the current directory (assumed to be the home directory, or a subfolder thereof) that risk failing the "getting started" (due to read-only file system).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will leave the user working with remote filesystems for the "hello world", and then come back to using local filesystems in the working with files section (that is mostly about mounting remote files, but anyway)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I was not able to fit the location of the .sif files (on the VM) with the mounting of the host $HOME...
Maybe it needs to move to a separate page, or maybe a separate section to not have to duplicate commands?

Copy link
Author

@afbjorklund afbjorklund Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will zoom out from the quick start and see where such a separate page would fit, in the user docs.
https://apptainer.org/docs/user/latest/

quick_start.rst Outdated Show resolved Hide resolved
@afbjorklund
Copy link
Author

afbjorklund commented Dec 7, 2023

By default, {Project} bind mounts /home/$USER, /tmp, and $PWD into your container at runtime.

Should that be using $HOME, or is it actually only mounting /home ? Guess I need to look at the code...

While it is possible to shell into the virtual machine,
it is also possible to call apptainer.lima on the host.

This makes it easier to interact with the local files,
and to copy the resulting SIF files to another location.

Signed-off-by: Anders F Björklund <[email protected]>
@afbjorklund afbjorklund changed the title Show how to use apptainer from the lima host Show where to store images in the lima instance Dec 7, 2023
@DrDaveD
Copy link
Contributor

DrDaveD commented Mar 6, 2024

@afbjorklund This is still waiting on you. However I think your question is probably addressed in sylabs/singularity-userdocs#198 which we plan to import via #239.

@afbjorklund
Copy link
Author

Thanks for the reminder, if it needs clarification after your updates we can come back to it and open another PR (if so)

@afbjorklund afbjorklund closed this Mar 6, 2024
@DrDaveD
Copy link
Contributor

DrDaveD commented Mar 6, 2024

I didn't mean it answered the entire question of the PR, that of showing where to store images in the lima instance. I just meant that it answers your last question regarding $HOME vs /home/$USER.

@afbjorklund
Copy link
Author

As far as I understand, there is no "standard" location for the images (sifs) - like there is with /var/lib/docker or ~/.local/share/containers/storage? So the user is free to pick any location, as long as it is not the (host) $HOME.

The cache directories under the (instance) $HOME work fine, like when it is auto-converting a docker:// reference. So in some sense it is using ~/.apptainer/cache, but I don't know if there are any "user accessible" directories there.

@afbjorklund
Copy link
Author

Also this is something that could use some more feedback, from actual users of Apptainer "on" their Mac hosts.

@DrDaveD
Copy link
Contributor

DrDaveD commented Mar 6, 2024

Yeah I really don't understand the issue since I'm not a user. I recall trying it on my old Mac but now my Mac has an Apple M2 so I assume it won't be able to use x86_64 containers anymore anyway.

If you wanted to recommend that people put things under ~/.apptainer/lima or ~/.apptainer/cache/ima I don't think those would conflict with anything.

@afbjorklund
Copy link
Author

afbjorklund commented Mar 6, 2024

From the "getting started", these commands work OOTB:

$ apptainer --debug run docker://alpine

$ apptainer run --containall docker://alpine

Mounting block [squashfs] image: /home/anders.linux/.apptainer/cache/oci-tmp/1314cd9ac423c23a30c4151aef273bd0df077f4219cca0b8027d6a837b65aae6

These are failing due to the default of having a read-only home:

$ apptainer pull docker://alpine

$ apptainer build alpine.sif docker://alpine

$ apptainer pull docker://ghcr.io/apptainer/lolcow

FATAL: While making image from oci registry: error copying image out of cache: could not open temporary file for copy: failed to create temporary file: open ./tmp-copy-1428213633: read-only file system

This "works", but does not have great performance for big images:

$ apptainer build /tmp/lima/lolcow_latest.sif docker://ghcr.io/apptainer/lolcow

$ cp /tmp/lima/lolcow_latest.sif .

$ apptainer run lolcow_latest.sif

Due to having to "scp" the .sif image, from the VM and to the VM.


https://apptainer.org/docs/user/main/quick_start.html

@afbjorklund
Copy link
Author

afbjorklund commented Mar 6, 2024

I assume it won't be able to use x86_64 containers anymore anyway.

You can use the binaries (without rebuilding them), but only through qemu-user or Rosetta emulation.

Theoretically you can run the whole VM in emulation but it is rather slow, though useful for e.g. RISC-V

See https://lima-vm.io/docs/config/multi-arch/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants