AWS Open Source Blog

Enhancing Developer Productivity: Finch’s Support for Development Containers and the Finch Daemon

In today’s fast-paced software development landscape, containerization has become an essential tool for building and deploying applications. With all the necessary tools and dependencies encapsulated in a container, developers can effortlessly set up and replicate development environments on various machines.

The key steps involved in building and running containers typically include:

  1. Building container images using Dockerfiles
  2. Running containers locally
  3. Pushing and pulling container images to registries
  4. Managing container networks and volumes

Finch is an open source command-line tool that helps developers build and run containers seamlessly. Finch provides a simple client along with a curated set of de facto standard open source components including Lima, nerdctl, containerd, and BuildKit for running and building containers.

Improving developer productivity has been a key focus for Finch since its inception. In our latest efforts, we are excited to announce two major advancements:

  1. Support for Visual Studio Code Dev Containers
  2. The Launch of the Finch Daemon

Using Finch with Development Containers in Visual Studio Code

Development containers provide repeatable, consistent development environments for individual developers or teams. Developers use these containers to build, test, and run applications during the software development process. Production deployment containers are optimized to efficiently run the final application, while development containers include additional tooling, libraries, and configurations. These additions are helpful for the developer workflow, but not necessary or desirable in a production setting. The purpose of development containers is to provide a consistent, repeatable environment for developers. In contrast, deployment containers focus on minimizing the runtime footprint and dependencies required to execute the application in production.

Previously, using development containers required Docker Desktop or alternative Docker options. With the release of Finch v1.4.1, you can now use Finch with development containers on all three major operating systems: macOS, Linux, and Windows.

The Visual Studio Code Dev Containers extension is a popular Visual Studio Code (VS Code) extensions, providing an integrated experience for using a container as a full-featured development environment directly within the VS Code editor.

Steps to Set Up Finch with Development Containers

Here’s how to set up and use Finch with the Visual Studio Code Dev Containers extension:

Instructions

  1. Install Finch version 1.4.1 or later.
  2. Verify the Finch version by running this command:
    finch --version
  3. Install Visual Studio Code
  4. Install the Dev Containers extension
  5. Verify you have VSCode and the Dev Containers Extension installed by running these commands:
    code --version
    code --list-extensions | grep ms-vscode-remote.remote-containers
  6. Configure Finch to use Dockercompat Mode:
    a. Since we’re using Finch instead of Docker Desktop. the Dockercompat configuration parameter will convert the Docker-like arguments into compatible nerdctl commands and arguments, which Finch will then run against containerd runtime.
    b. Refer to the Finch configuration documentation to find examples of finch.yaml configurations for your operating system. Specifically, you’ll need to include this configuration option:
    dockercompat: true
  7. Update the Visual Studio Code Dev Containers extension with these settings:
    a. VS Code Settings → Extensions → Dev Containers → Extension Settings or use search string @ext:ms-vscode-remote.remote-containers in settings page
    b. Set the “Docker Compose executable name or path” to <path>/<to>/finch compose
    c. Disable Docker Credential Helper by unchecking the checkbox.
    d. Set the “Docker (or Podman) executable name or path” to <path>/<to>/finch
    e. Additional settings when using Finch with Visual Studio Code Dev Containers on Windows:
    i. Set the “Execute In WSLDistro” option to path of Finch executable <path>/<to>/finch.exe.
    ii. Disable the Mount Wayland Socket by unchecking the checkbox.
  8. Initialize the Finch VM (only for MacOS or Windows):

finch vm init

9. Clone a sample Go application:

a. Open your terminal and navigate to the directory where you want to clone the application:

git clone https://github.com/go-training/helloworld.git

b. Change into the cloned directory:

cd helloworld

10. Create a development container configuration file:

mkdir -p .devcontainer && touch .devcontainer/devcontainer.json

Populate the devcontainer.json file with this configuration:

{
    "name": "GoApp",
    "image": "mcr.microsoft.com/devcontainers/go:1-1.22-bookworm",
    "containerEnv": {
      "GOPROXY": "direct"
    }
}

11. Open the helloworld project in VS Code and it will detect the development container configuration file. It then prompts you to Reopen in Container to launch the Dev container. Click “Reopen in Container” to launch the dev container. Alternatively, you can open the development container through the Command Palette with the “Dev Containers: Reopen in Container” command.

12. Verify that the environment is created successfully by interacting with a terminal inside the container.

container terminal

This output confirms that the created development container has go version 1.22.

13. You can also verify the development container environment status using the finch command:

finch ps 
 
CONTAINER ID    IMAGE                                                 COMMAND                   CREATED          STATUS    PORTS    NAMES
4dd363be58f6    mcr.microsoft.com/devcontainers/go:1-1.22-bookworm    "/sbin/tini -- /bin/…"    5 minutes ago    Up                 go-4dd36

Note:

Users may encounter an Identifier length limit of 76 when using a development container due to a known issue with the nerdctl version. We can overcome the issue by setting the –name argument within the runArgs entity of the devcontainer.json file to override the container name. The name can be any unique value (less than 76 characters). For example, use this option to override the container name with the workspace directory:

"runArgs": ["--name", "${localWorkspaceFolderBasename}"],

This issue has been fixed in nerdctl version 2.0. At the time of testing, the version of nerdctl being used with Finch was 1.7.7. Users can check the version of nerdctl being used by Finch with this command:

finch version

Now that you have Finch with development containers in VS Code, you can take full advantage of this integration. You can use development containers as full-featured development environments. They allow you to separate the tools, libraries, and runtimes needed for a codebase into a container, which can then be run locally or remotely.

Finch Daemon

The Finch Daemon is an open source project that implements a subset of the Docker Engine API specification (v 1.43). The primary goal of this project is to decouple the programmatic dependencies on the Docker Engine, allowing developers to leverage the Docker API without being tightly coupled to the Docker runtime.

The Finch Daemon creates a dockerd-like socket endpoint, but it works directly with the containerd runtime instead of the Docker Engine. This allows popular Docker client libraries, such as docker-py, go-dockerclient, and AWS Serverless Application Model (AWS SAM) to continue to work seamlessly by delegating the commands to the containerd runtime.

Some key features of the Finch Daemon include:

  • A partial implementation of the Docker API Spec v1.43
  • Native support for Linux environments
  • Shared namespace with Finch, enabling visibility into containers, images, networks, and volumes

It is important to note that not all APIs and fields of the Docker API are fully supported by the Finch Daemon. This is because the project’s focus is on meeting the needs of Finch users rather than aiming for complete Docker API compatibility.

By decoupling the Docker API from the Docker Engine, Finch Daemon provides greater flexibility and portability for software that relies on the Docker API. This alignment with the containerd runtime also helps to future-proof Finch and its ecosystem, ensuring a consistent container development experience across different platforms and runtimes.

The Finch Daemon project is actively accepting contributions to improve API compatibility and expand functionality. Your participation will help shape the future of this important component within the Finch ecosystem.

Conclusion

The introduction of Finch’s support for developer containers and the Finch Daemon represent a significant step forward in enhancing the developer experience. We encourage you to try out Finch and explore the benefits it can bring to your development process. Whether you’re working on a new project or looking to streamline an existing one, Finch’s integrations with tools like VS Code Dev Containers can help you create a seamless, productivity-boosting development environment.

To get started, visit the Finch and Finch Daemon projects for installation instructions and further guidance. The Finch team will continue to evolve the product in public, building out milestones and a roadmap with input from our users. We also welcome your feedback, contributions, and participation in shaping the future of Finch and the Finch Daemon projects.

Hemanth AVS

Hemanth AVS

Hemanth is a Sr. Containers Specialist Solutions Architect at AWS. He helps customers modernize their applications and build application platforms using AWS container services. He is passionate about cloud and cloud native technologies.

Ashok Srirama

Ashok Srirama

Ashok is a Sr. Containers Specialist Solutions Architect at Amazon Web Services, based in Washington Crossing, PA. He specializes in serverless applications, containers, and architecting distributed systems. When he’s not spending time with his family, he enjoys watching cricket, and driving.

Sai Charan Teja Gopaluni

Sai Charan Teja Gopaluni

Sai Charan Teja Gopaluni is a Sr.Solutions Architect at Amazon Web Services. In his role as a subject matter expert, he enjoys helping customers design modern, scalable and secure container based applications. Outside of the work, he enjoys playing Tennis and watching Soccer.