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

feat: Add native lima Docker provider support #5892

Merged
merged 14 commits into from
Mar 11, 2024
Merged

Conversation

rfay
Copy link
Member

@rfay rfay commented Feb 23, 2024

The Issue

Colima has gotten quite unstable for lots of people, but it's just a wrapper on Lima, and so we should be able to use Lima directly as another open-source alternative.

How This PR Solves The Issue

It's worth considering whether we should do this at all, as adding more options doesn't necessarily help people or our support environment.

TODO

  • Docs
  • Turn on tests (preferably without putting red marks on other PRs)
  • Make it pass tests

Manual Testing Instructions

Use the docs to start a lima instance, then do a simple quickstart test.

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

Copy link

github-actions bot commented Feb 25, 2024

@rfay
Copy link
Member Author

rfay commented Mar 8, 2024

Fails TestDdevAllDatabases on tb-macos-arm64-7 with non-writable filesystem:
https://buildkite.com/ddev/macos-lima/builds/12#018e1f6d-091a-4022-8753-f14e26bb1c74

TestWritableFilesDirectory on tb-macos-arm64-6: https://buildkite.com/ddev/macos-lima/builds/18#018e2142-c31e-405c-9db3-3a416e2790f1

Copy link
Collaborator

@rpkoller rpkoller left a comment

Choose a reason for hiding this comment

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

just left a few comments early on. just after leaving comments on the colima quickstart i noticed that there are certain overlaps for those two and it might be a good thing to keep things consistent across quickstarts. and would it make sense since colima and rancher are based on lima to place lima in front of the two?

@@ -46,6 +45,27 @@ You’ll need a Docker provider on your system before you can [install DDEV](dde
!!!warning "Colima can only work in your home directory unless you do further configuration"
By default, Colima only mounts your home directory, so it’s easiest to use it in a subdirectory there. See the `~/.colima/default/colima.yaml` for more information, or notes in [colima.yaml](https://github.com/abiosoft/colima/blob/fc948f8f055600986f87e29e3e632daf56ac8774/embedded/defaults/colima.yaml#L130-L143).

### Lima

[Lima](https://github.com/lima-vm/lima) is a free and open-source project supported by the [Cloud Native Computing Foundation](https://cncf.io/).
Copy link
Collaborator

Choose a reason for hiding this comment

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

one note. colima currently states that bundles a container management tool called [Lima](https://github.com/lima-vm/lima) with a Docker (Linux) backend.. with lima not an option in this list it was ok to phrase it that way but as soon as lima is added i would rephrase it. and i would also add a note to rachner that it is based on lima. that has no note about that yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, can't understand your question but feel free to propose something.


[Lima](https://github.com/lima-vm/lima) is a free and open-source project supported by the [Cloud Native Computing Foundation](https://cncf.io/).

1. Install Lima with `brew install lima`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would make step 1 and 2 consistent with Colima.

  1. Run docker help to verify if the Docker client is installed. In case of an error, install it Homebrew by running brew install docker (slightly altered the Colima version might be adjusted accordingly?)
  2. Install Lima with brew install lima

Copy link
Member Author

Choose a reason for hiding this comment

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

I like it better this way, didn't like the other one as much.

docs/content/users/install/docker-installation.md Outdated Show resolved Hide resolved
2. Install the `docker` client if you don't already have it with `brew install docker`.
3. Create a default Lima setup with 4 CPUs, 6GB memory, 100GB storage, and Cloudflare DNS, adjusting as needed:
```
limactl create --vm-type=vz --mount-type=virtiofs --mount-writable --memory=6 --cpus=4 --disk=100 template://docker
Copy link
Collaborator

Choose a reason for hiding this comment

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

i am cautious and a bit afraid of mounting the entire home directory, most of the lima maintainers share the same worry. That is the reason why out of the box only the lima temp directory is added. but the rancher maintainer is the only lima maintainer who mounts his entire homedirectory for convenience reasons. just as a note. i am ok with it but personally i only use --mount="~/Sites:w" (with Sites being the directory i store all my projects)

Copy link
Member Author

Choose a reason for hiding this comment

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

I understand that your caution, but this is the default behavior and doing it otherwise creates enormous support problems.

3. Create a default Lima setup with 4 CPUs, 6GB memory, 100GB storage, and Cloudflare DNS, adjusting as needed:
```
limactl create --vm-type=vz --mount-type=virtiofs --mount-writable --memory=6 --cpus=4 --disk=100 template://docker
docker context create lima-default --docker "host=unix://$HOME/.lima/default/sock/docker.sock"
Copy link
Collaborator

Choose a reason for hiding this comment

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

it probably should be noted that this command has only to be run once after the initial creation of the VM. and this line as well as the next (docker context use) are also output by default. they are part of the messagethat is defined in the instances yaml file.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is shown as part of the first-time setup.

docker context create lima-default --docker "host=unix://$HOME/.lima/default/sock/docker.sock"
docker context use lima-default
```
After the initial run above, you can use `limactl start`. Run `limactl list` to see configured setup.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
After the initial run above, you can use `limactl start`. Run `limactl list` to see configured setup.
After the initial setup, you can start your instance with `limactl start`. Run `limactl --help` to see the list of available commands.

instead of adding the command to see the configured setup i think providing the help command to get the list of all available command might be more helpful (which also includes the list command)

Copy link
Member Author

Choose a reason for hiding this comment

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

I like it as is. People have to branch out to learn more.

!!!warning "Docker contexts let the Docker client point at the right Docker server"
The Docker provider you're using is selected with `docker context`. You can see the available contexts with `docker context ls` and the currently selected one with `docker context show`. With the setup above you'll want `docker context use lima-default`.

!!!warning "Lima only mounts filesystems in your home directory unless you do further configuration"
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as for the colima quickstart. i think it would make sense to clarify that those mounts are not necessary for lima to run but for ddev projects to run?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here we're only interested in people running DDEV projects. People can do other things with Lima if they want to.

If people don't put their projects on a filesystem that Lima mounts then DDEV is nonfunctional. Most people put their projects somewhere in the homedir.

Copy link
Member Author

@rfay rfay left a comment

Choose a reason for hiding this comment

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

Thanks for taking such a good look @rpkoller and thanks for all your expertise in this area!

2. Install the `docker` client if you don't already have it with `brew install docker`.
3. Create a default Lima setup with 4 CPUs, 6GB memory, 100GB storage, and Cloudflare DNS, adjusting as needed:
```
limactl create --vm-type=vz --mount-type=virtiofs --mount-writable --memory=6 --cpus=4 --disk=100 template://docker
Copy link
Member Author

Choose a reason for hiding this comment

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

I understand that your caution, but this is the default behavior and doing it otherwise creates enormous support problems.

3. Create a default Lima setup with 4 CPUs, 6GB memory, 100GB storage, and Cloudflare DNS, adjusting as needed:
```
limactl create --vm-type=vz --mount-type=virtiofs --mount-writable --memory=6 --cpus=4 --disk=100 template://docker
docker context create lima-default --docker "host=unix://$HOME/.lima/default/sock/docker.sock"
Copy link
Member Author

Choose a reason for hiding this comment

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

This is shown as part of the first-time setup.

docker context create lima-default --docker "host=unix://$HOME/.lima/default/sock/docker.sock"
docker context use lima-default
```
After the initial run above, you can use `limactl start`. Run `limactl list` to see configured setup.
Copy link
Member Author

Choose a reason for hiding this comment

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

I like it as is. People have to branch out to learn more.

!!!warning "Docker contexts let the Docker client point at the right Docker server"
The Docker provider you're using is selected with `docker context`. You can see the available contexts with `docker context ls` and the currently selected one with `docker context show`. With the setup above you'll want `docker context use lima-default`.

!!!warning "Lima only mounts filesystems in your home directory unless you do further configuration"
Copy link
Member Author

Choose a reason for hiding this comment

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

Here we're only interested in people running DDEV projects. People can do other things with Lima if they want to.

If people don't put their projects on a filesystem that Lima mounts then DDEV is nonfunctional. Most people put their projects somewhere in the homedir.

@rfay rfay marked this pull request as ready for review March 11, 2024 13:35
@rfay rfay requested review from a team as code owners March 11, 2024 13:35
@rfay rfay merged commit 60831ee into ddev:master Mar 11, 2024
2 of 8 checks passed
@rfay rfay deleted the 20240222_lima branch March 11, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants