9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

docker image を小さくしたりするの方法の1つ

Last updated at Posted at 2016-10-19

Google Cloud Container Builder というクラウドで docker image をビルドするためのサービスがあるのですが、 2016-10-19 現在 beta で 120分/日制限があったり、ローカルで実行できなくてイヤなので、 Build Requests (config) のフォーマットを読んで実行できるツールを作ったのでその宣伝です。

cb - a container builder

基本的には docker image とそれを docker run するときの引数を指定して、順番に実行するだけなのですが、 Build process に書いてあるように、 /var/run/docker.sock と各ステップで共有している /workspace を volume でマウントしてるのがキモです。

具体的にどんなことができるかというと、

  • docker コマンドを含む image 実行することでコンテナ内で docker build できる
  • ビルドした image をさらに次のステップで実行することで結果だけ /workspace に取り出したりできる
  • で、その結果のファイルをビルドコンテキストとして追加した小さい image をビルドできる

たとえば、

  • 普通に golang image を base image として普通に go のバイナリを含むimage をビルドしてから go バイナリだけを取り出して from scratch な image をつくる
  • web アプリケーションのフロントエンドの javascript の bundle や transpile をした bundle.js の結果だけを取り出す
  • あとは、べつに docker image を作らなくても docker run でできることはなんでもできるはず。想像力ないのでいい例が思いつかない...。

細かいことは github repo みてください。
https://github.com/hiroshi/cb

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?