TranslateProject/sources/tech/20220915 How I switched from Docker Desktop to Colima.md
2022-09-20 08:38:58 +08:00

5.8 KiB
Raw Blame History

How I switched from Docker Desktop to Colima

Colima is a Docker Desktop alternative for macOS and Linux that's now supported by DDEV.

Getting started with Perlbrew

Image by: freephotocc via Pixabay CC0

DDEV is an open source tool that makes it simple to get local PHP development environments up and running within minutes. Its powerful and flexible as a result of its per-project environment configurations, which can be extended, version controlled, and shared. In short, DDEV aims to allow development teams to use containers in their workflow without the complexities of bespoke configuration.

DDEV replaces more traditional AMP stack solutions (WAMP, MAMP, XAMPP, and so on) with a flexible, modern, container-based solution. Because it uses containers, DDEV allows each project to use any set of applications, versions of web servers, database servers, search index servers, and other types of software.

In March 2022, the DDEV team announced support for Colima, an open source Docker Desktop replacement for macOS and Linux. Colima is open source, and by all reports its got performance gains over its alternative, so using Colima seems like a no-brainer.

Migrating to Colima

First off, Colima is almost a drop-in replacement for Docker Desktop. I say almost because some reconfiguration is required when using it for an existing DDEV project. Specifically, databases must be reimported. The fix is to first export your database, then start Colima, then import it. Easy.

Colima requires that either the Docker or Podman command is installed. On Linux, it also requires Lima.

Docker is installed by default with Docker Desktop for macOS, but its also available as a stand-alone command. If you want to go 100% pure Colima, you can uninstall Docker Desktop for macOS, and install and configure the Docker client independently. Full installation instructions can be found on the DDEV docs site.

An image of the container technology stack.

Image by: (Mike Anello,CC BY-SA 4.0)

If you choose to keep using both Colima and Docker Desktop, then when issuing docker commands from the command line, you must first specify which container you want to work with. More on this in the next section.

Install Colima on macOS

I currently have some local projects using Docker, and some using Colima. Once I understood the basics, its not too difficult to switch between them.

  1. To get started, install Colima using Homebrew brew install colima
  2. ddev poweroff (just to be safe)
  3. Next, start Colima with colima start --cpu4--memory 4. The --cpu and --memory options only have to be done once. After the first time, only colima start is necessary.
  4. If youre a DDEV user like me, then you can spin up a fresh Drupal 9 site with the usual ddev commands (ddev config, ddev start, and so on.) Its recommended to enable DDEVs mutagen functionality to maximize performance.

Switching between a Colima and Docker Desktop

If youre not ready to switch to Colima wholesale yet, its possible to have both Colima and Docker Desktop installed.

  1. First, poweroff ddev:ddev poweroff
  2. Then stop Colima: colima stop
  3. Now run docker context use default`` to tell the Docker client which container you want to work with. The name default refers to Docker Desktop for Mac. When colima start is run, it automatically switches Docker to the colima context.
  4. To continue with the default (Docker Desktop) context, use the ddev start command.

Technically, starting and stopping Colima isnt necessary, but the ddev poweroff command when switching between two contexts is.

Recent versions of Colima revert the Docker context back to default when Colima is stopped, so the docker context use default command is no longer necessary. Regardless, I still use docker context show to verify that either the default (Docker Desktop for Mac) or colima context is in use. Basically, the term context refers to which container provider the Docker client routes commands to.

Try Colima

Overall, Im liking what I see so far. I havent run into any issues, and Colima-based sites seem a bit snappier (especially when DDEVs Mutagen functionality is enabled). I definitely foresee myself migrating project sites to Colima over the next few weeks.

This article originally appeared on the DrupalEasy blog and is republished with permission.


via: https://opensource.com/article/22/9/docker-desktop-colima

作者:Michael Anello 选题:lkxed 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出