DEV Community

Ricardo Sueiras for AWS

Posted on

Using Finch with Dev Containers on VSCode

At the beginning of 2024 I switched from using Docker Desktop on my Mac, to using Finch, an open source alternative. I am currently using an M1 (a mighty fine machine!), and I have blogged about some of the ways you can switch to using open source alternatives as part of your day to day life as a developer. Over the weekend I was trying to get Dev Containers up and running (inspired by this blog post), but found myself struggling. I was encountering lots of errors such as:

[6875 ms] Command in container failed: mv -n /vscode/vscode-server/bin/linux-arm64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e_1748041558617/* /vscode/vscode-server/bin/linux-arm64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e && rmdir /vscode/vscode-server/bin/linux-arm64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e_1748041558617
[6876 ms] rmdir: failed to remove '/vscode/vscode-server/bin/linux-arm64/848b80aeb52026648a8ff9f7c45a9b0a80641e2e_1748041558617': Directory not empty
[6876 ms] Exit code 1
Enter fullscreen mode Exit fullscreen mode

or the equally helpful

[728 ms] Setting up container for folder or workspace: /workspaces/helloworld
[728 ms] Host authority: ssh-remote+01970446-e257-7762-b783-5700c68bd9c2.gitpod.remote
[816 ms] Start: Check Docker is running
[816 ms] Start: Run: podman version
[861 ms] CodeError(ProcessSpawnFailed(Os { code: 2, kind: NotFound, message: "No such file or directory" }))
[864 ms] Docker returned an error code ENOENT, message: CodeError(ProcessSpawnFailed(Os { code: 2, kind: NotFound, message: "No such file or directory" }))
Enter fullscreen mode Exit fullscreen mode

I was ready to give up, but a colleague (thank you Kris Nielander!) helped me get this up and running. This blog post is for those of you who want to get Dev Containers up and running on VSCode using Finch.

What you will need

This is what I have setup, so I guess these are the minimum requirements to get this solution working:

  • VSCode (I am running 1.100.2) with the Remote SSH and Dev Containers extensions installed
  • Finch (I am running version 1.7.0, but later versions should all work ok)

Setting up Finch to work with devcontainers

Step One

The first thing to do is update your finch.yaml (in the ~/.finch directory), to add a line as follows:

dockercompat: true
Enter fullscreen mode Exit fullscreen mode

Here is my complete finch.yaml file for reference.

cpus: 3
memory: 8GiB
rosetta: false
vmType: vz
dockercompat: true
Enter fullscreen mode Exit fullscreen mode

Once you have updated it, I restarted finch via finch vm stop and finch vm start

Step Two

I created a bash file as a proxy for Docker. It doesn't matter where this is as long as its in your path. In my case I decided to put this in "/usr/local/bin", and I created the following:

touch /usr/local/bin/docker
chmod +x /usr/local/bin/docker
Enter fullscreen mode Exit fullscreen mode

(I had to use sudo) and then I edited this file to contain the following

#!/bin/bash
exec finch "$@"
Enter fullscreen mode Exit fullscreen mode

After saving this file, I check to make sure that I could run this fake docker against existing Finch commands (e.g. docker system info or docker --version).

Step Three

From VSCode, from the command palette I selected Dev Containers: Settings to bring up the settings, and then made the following changes:

  • DISABLE the "Dev > Dev Containers: Cache Volume" (this is enabled by default)
  • DISABLE the "Dev > Dev Containers: Docker Credentials Help" (this is enabled by default)
  • Ensure that you just have "docker compose" in the "Dev > Dev Containers: Docker Compose Path
  • Ensure that you just have "docker" in the "Dev > Dev Containers: Docker Path

Image description

(Screenshot of my VSCode settings)

After saving these settings, you are finished.

Ready to go

Once you have made these changes, you should now be able to run Dev Containers within VSCode using Finch.

I have tried these natively within VSCode (both creating NEW as well as using existing projects), but also works for tools like GitPod (which I am currently experimenting with).

Top comments (4)

Collapse
 
sawyerwolfe profile image
Sawyer Wolfe •

Thanks for sharing this! I’ve been wanting to move away from Docker Desktop on my Mac, and your step-by-step guide is exactly what I needed. I’m going to try updating my finch.yaml and set up the bash proxy as you described. Looking forward to running my dev containers with Finch soon!

Collapse
 
094459 profile image
Ricardo Sueiras •

Let me know how you get on, as I have not tested it as rigorously as I normally do for these things. It is holding out so far though.

Collapse
 
nevodavid profile image
Nevo David •

Pretty cool you stuck with it even after all those errors-it pays off not bailing early.

Collapse
 
094459 profile image
Ricardo Sueiras •

Always, although if it wasn't for my colleague to help finally unlock the solution, this post would never have happened. Persistence + People = Good Outcome!