フラミナル

考え方や調べたことを書き殴ります。IT技術系記事多め

【新規ツール探し】ローカルマシンで仮想環境とコンテナを動かすFinchとは

  • 記事作成日:2022/11/24

情報

名前 URL
Github https://github.com/runfinch/finch
公式サイト
デモサイト
開発母体 CNCF / AWS
version 0.1.0
言語 Go
価格 無料
ライセンス Apache-2.0 license

何ができるもの?

Docker on Desktop を利用せずに、Mac 環境でコンテナを使用できる。 裏側では containerd / nerdctl / Lima を使っている。

  • containerd : コンテナランタイム
  • nerdctl : containerd を操作する CLI。最新の containerd の機能を使いたいモチベで開発されていて、Docker の UI/UX に似せてる。
  • Lima : 仮想マシンを Linux や Mac で動かす

使い方

Releases · runfinch/finch · GitHub からダウンロード

install Finch

  $ finch vm init 

Uninstall Finch

sudo bash /Applications/Finch/uninstall.sh 

ただし2022/11/24時点で以下のエラーで起動できず。

❯ finch vm init
INFO[0000] Initializing and starting Finch virtual machine... 
INFO[0064] Finch virtual machine started successfully   
FATA[0064] failed to setup ssh client: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain 

ただし、build や run などは使用できた。

外部イメージの起動

❯ finch run --rm public.ecr.aws/finch/hello-finch
public.ecr.aws/finch/hello-finch:latest:                                          resolved       |++++++++++++++++++++++++++++++++++++++| 
index-sha256:a71e474da9ffd6ec3f8236dbf4ef807dd54531d6f05047edaeefa758f1b1bb7e:    done           |++++++++++++++++++++++++++++++++++++++| 
manifest-sha256:705cac764e12bd6c5b0c35ee1c9208c6c5998b442587964b1e71c6f5ed3bbe46: done           |++++++++++++++++++++++++++++++++++++++| 
config-sha256:6cc2bf972f32c6d16519d8916a3dbb3cdb6da97cc1b49565bbeeae9e2591cc60:   done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1:    done           |++++++++++++++++++++++++++++++++++++++| 
layer-sha256:ec080f7c92e9eb0227d60951f7c779648989116d97a5926f3e8684d4e46df196:    done           |++++++++++++++++++++++++++++++++++++++| 
elapsed: 2.8 s                                                                    total:  2.5 Ki (903.0 B/s)                                       

                            @@@@@@@@@@@@@@@@@@@                                 
                        @@@@@@@@@@@@    @@@@@@@@@@@                             
                      @@@@@@@                  @@@@@@@                          
                    @@@@@@                        @@@@@@                        
                  @@@@@@                            @@@@@                       
                 @@@@@                      @@@#     @@@@@@@@@                  
                @@@@@                     @@   @@@       @@@@@@@@@@             
                @@@@%                     @     @@            @@@@@@@@@@@       
                @@@@                                               @@@@@@@@     
                @@@@                                         @@@@@@@@@@@&       
                @@@@@                                  &@@@@@@@@@@@             
                 @@@@@                               @@@@@@@@                   
                  @@@@@                            @@@@@(                       
                   @@@@@@                        @@@@@@                         
                     @@@@@@@                  @@@@@@@                           
                        @@@@@@@@@@@@@@@@@@@@@@@@@@                              
                            @@@@@@@@@@@@@@@@@@


Hello from Finch!

Visit us @ github.com/runfinch

Nginx を起動してみる

❯ finch run -d  -p 8080:80 nginx
561107ca987cd3753bf00817b9d440a7b76dab6ddd5a33a8ecfd24d059dd0046

❯ curl localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

build

❯ git clone git@github.com:runfinch/finch.git
❯ cd finch/contrib/hello-finch
❯ finch build . -t hello-finch                   
[+] Building 25.1s (11/11) FINISHED                                                                                                                
 => [internal] load build definition from Dockerfile                                                                                          0.1s
 => => transferring dockerfile: 322B                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                             0.0s
 => => transferring context: 2B                                                                                                               0.0s
 => [internal] load metadata for public.ecr.aws/docker/library/golang:1.19                                                                    2.0s
 => [builder 1/4] FROM public.ecr.aws/docker/library/golang:1.19@sha256:dc76ef03e54c34a00dcdca81e55c242d24b34d231637776c4bb5c1a8e8514253     19.9s
 => => resolve public.ecr.aws/docker/library/golang:1.19@sha256:dc76ef03e54c34a00dcdca81e55c242d24b34d231637776c4bb5c1a8e8514253              0.0s
 => => sha256:cd807e8b483974845eabbdbbaa4bb3a66f74facd8c061e01e923e9f1da608271 0B / 157B                                                     22.8s
 => => sha256:fecd6ba4b3f93b6c90f4058b512f1b0a44223ccb3244f0049b16fe2c1b41cf45 112.20MB / 115.13MB                                           22.8s
 => => sha256:4fb255e3f99867ec7a2286dfbbef990491cde0a5d226d92be30bad4f9e917fa4 81.37MB / 81.37MB                                             22.8s
 => => sha256:426e8acfed2a5373bd99b22b5a968d55a148e14bc0e0f51c5cf0d779afefe291 53.48MB / 54.68MB                                             22.8s
 => => sha256:3d7b1480fa4dae5cbbb7d091c46ae0ae52f501418d4cfeb849b87023364e2564 10.49MB / 10.87MB                                             22.6s
 => => sha256:a3e29af4daf3531efcc63588162e8bdcf3434aa5d72df4eabeb5e20c6695e303 5.15MB / 5.15MB                                                1.0s
 => => sha256:077c13527d405646e2f6bb426e04716ae4f8dd2fdd8966dcb0194564a2b57896 53.70MB / 53.70MB                                             19.4s
 => => extracting sha256:077c13527d405646e2f6bb426e04716ae4f8dd2fdd8966dcb0194564a2b57896                                                     1.5s
 => => extracting sha256:a3e29af4daf3531efcc63588162e8bdcf3434aa5d72df4eabeb5e20c6695e303                                                     0.2s
 => => extracting sha256:3d7b1480fa4dae5cbbb7d091c46ae0ae52f501418d4cfeb849b87023364e2564                                                     0.2s
 => => extracting sha256:426e8acfed2a5373bd99b22b5a968d55a148e14bc0e0f51c5cf0d779afefe291                                                     1.5s
 => => extracting sha256:4fb255e3f99867ec7a2286dfbbef990491cde0a5d226d92be30bad4f9e917fa4                                                     1.6s
 => => extracting sha256:fecd6ba4b3f93b6c90f4058b512f1b0a44223ccb3244f0049b16fe2c1b41cf45                                                     3.3s
 => => extracting sha256:cd807e8b483974845eabbdbbaa4bb3a66f74facd8c061e01e923e9f1da608271                                                     0.0s
 => [internal] load build context                                                                                                             0.1s
 => => transferring context: 2.16kB                                                                                                           0.0s
 => [builder 2/4] WORKDIR /build                                                                                                              0.0s
 => [builder 3/4] COPY . .                                                                                                                    0.1s
 => [builder 4/4] RUN CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o hello-finch .                          2.6s
 => [stage-1 1/2] COPY --from=builder /build/hello-finch /app/                                                                                0.1s
 => [stage-1 2/2] WORKDIR /app                                                                                                                0.0s
 => exporting to image                                                                                                                        0.2s
 => => exporting layers                                                                                                                       0.2s
 => => exporting manifest sha256:f9dfe0d4a7dd7636e33b6408252bfc13882aa7a34fc08668f76a8b9fd7e32aaa                                             0.0s
 => => exporting config sha256:67e9b6db6f6494279cd49c968547c5778c6e0cedc7bbf554975ddc0b7bd83c33                                               0.0s
 => => naming to docker.io/library/hello-finch:latest                                                                                         0.0s
 => => unpacking to docker.io/library/hello-finch:latest                                                                                      0.1s

dockerfile としては特に変わりがないので、利用しやすい。

FROM public.ecr.aws/docker/library/golang:1.19 AS builder
WORKDIR /build
COPY . .

RUN CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o hello-finch .

FROM scratch
COPY --from=builder /build/hello-finch /app/
WORKDIR /app
ENTRYPOINT ["./hello-finch"]

利用シーン

Docker Desktop の代替として無料で利用できる。

登場背景

by DeepL

非 Linux ホスト上で Linux コンテナを構築して実行する方法として、既存の商用製品や、目的に応じたオープンソース・プロジェクトが数多く存在します。企業は、既存のオープンソースコンポーネントからシンプルなコマンドラインツールを組み立てることができるかもしれませんが、ほとんどの企業は、開発者がツールの構築ではなく、アプリケーションの構築に集中することを望んでいます。

Introducing Finch: An Open Source Client for Container Development | AWS Open Source Blog

気にすること

  • まだ新しいのですぐにチーム全員で使うには使いづらい。
    • ただ、既存のツールを合体しているものなので動作は安定しているイメージ
  • 無償で利用できるのは非常に魅力的(逆に DockerDesktop を普通に利用できているなら採用のイメージが湧かない)
  • Docker に縛られないコンテナ開発ができる

リンク