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

Add Colima installation over Docker Desktop #96

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 126 additions & 1 deletion dev_envs/mac-env-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ xcode-select --install

### Docker ###

Download the latest stable [Docker for Mac](https://www.docker.com/docker-mac).
> [!NOTE]
> [Colima](#colima-a-docker-alternative) is our preferred solution on macOS.

Download the latest stable [Docker Desktop on Mac](https://www.docker.com/products/docker-desktop/).
Install it by double-clicking the downloaded `dmg` file and dragging the
Docker application file to the `Applications` folder.

Expand Down Expand Up @@ -106,6 +109,128 @@ After installing Brew, you'll want to install other useful
packages. We recommend installing all the packages specified in the
[CISA `laptop` script repository](https://github.com/cisagov/laptop/blob/master/Brewfile).

### Colima: A Docker alternative ###
Copy link
Member

@mcdonnnj mcdonnnj Apr 30, 2024

Choose a reason for hiding this comment

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

I would like this whole section to be a sub-section for Docker (above). It still relies on Docker under the hood (by default) and simply provides an alternative for Docker Desktop.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mcdonnnj see here 8ce2503


For individuals or businesses seeking a container solution without
the licensing conditions associated with [Docker Desktop](https://www.docker.com/pricing/faq/)
, [Colima](https://github.com/abiosoft/colima) offers a compelling
open-source alternative. Compatible with both MacOS and Linux,
michaelsaki marked this conversation as resolved.
Show resolved Hide resolved
Colima facilitates running containers directly using Docker
commands without the need for Docker Desktop.

#### Installing Colima ####

**Prerequisites:** If Docker Desktop is installed on your system,
uninstall it before proceeding.

**Installation Steps:**

1. Install Colima and Docker command-line tools using Homebrew:

```console
brew install colima docker docker-compose
```

1. Verify the installation by starting Colima:

```console
colima start
```

This initializes the Docker daemon within a lightweight VM.
The first startup may take a moment.

1. Confirm Docker is operational:

```console
docker
```

You should see the Docker usage menu.

1. Verify `docker-compose` is working:
michaelsaki marked this conversation as resolved.
Show resolved Hide resolved

```console
docker-compose
michaelsaki marked this conversation as resolved.
Show resolved Hide resolved
```

The `docker-compose` usage menu should appear.
michaelsaki marked this conversation as resolved.
Show resolved Hide resolved

### Optional configurations ###

Enhance your Colima setup with the following optional configurations:

#### Docker Compose as a Docker plugin ####
Copy link
Member

Choose a reason for hiding this comment

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

So the docker-compose formula is the Compose plugin. You can see in the formula's code that it's pulling down the latest version. It just creates a docker-compose binary that is symlinked into the plugins directory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Verified it on my end. Everything looks good without the config stuff.

See here: 8ce2503


Convert `docker-compose` to a Docker plugin for streamlined commands:

1. Create a directory for Docker CLI plugins:

```console
mkdir -p ~/.docker/cli-plugins
```

1. Symlink the `docker-compose` command:

```console
ln -sfn $(brew --prefix)/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose
```

1. Verify by running:

```console
docker compose
```

Ensure the `docker compose` usage menu is displayed.

#### Installing Buildx ####
Copy link
Member

Choose a reason for hiding this comment

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

This is also already installed as a Docker plugin by the formula per the formula's code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See here: 8ce2503


Buildx is necessary for building some Docker containers:

1. Install Buildx with Homebrew:

```console
brew install docker-buildx
```

1. Symlink Buildx to the CLI plugins directory:

```console
ln -sfn $(brew --prefix)/opt/docker-buildx/bin/docker-buildx ~/.docker/cli-plugins/docker-buildx
```

#### Customizing VM resources ####

To customize the VM's resources, such as CPUs, memory, and disk space:

1. Stop Colima:

```console
colima stop
```

1. Restart with desired specifications:

```console
colima start --cpu 4 --memory 4 --disk 100
```

### Support applications that are unaware of Docker context ###

In your .zshrc profile add the following configuration.
michaelsaki marked this conversation as resolved.
Show resolved Hide resolved

```console
michaelsaki marked this conversation as resolved.
Show resolved Hide resolved
# Set env variable for Colima compatibility with Docker
export DOCKER_HOST=unix://$HOME/.colima/default/docker.sock
```

> [!NOTE]
> This configuration directs Docker client tools to communicate with the
> Docker daemon managed by Colima, ensuring that Docker commands and
> applications (e.g. Molecule) function as expected without Docker Desktop.
michaelsaki marked this conversation as resolved.
Show resolved Hide resolved
> For more information, see [here](https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock-is-the-docker-daemon-running).

### Environment configuration ###

For portability between computers and environments, you may want to switch
Expand Down
Loading