LoginSignup
148
111

More than 5 years have passed since last update.

docker buildのオプションまとめ

Posted at

docker build時のオプションまとめ

対象のDockerバージョン

bash
[root@master cent_mount]# docker version
Client version: 1.6.2.el7
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): c3ca5bb/1.6.2
OS/Arch (client): linux/amd64
Server version: 1.6.2.el7
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): c3ca5bb/1.6.2
OS/Arch (server): linux/amd64

詳細は man docker build より

-f, --file=PATH/Dockerfile

bash
Path to the Dockerfile to use. If the path is a relative path then it must be relative to the current directory. The file  must  be  within  the build context. The default is Dockerfile.

Dockerfileの格納パス。相対パス指定をした場合は、カレントディレクトリからの相対となる。ファイルはビルドコンテキストに内包される。

--force-rm=true|false

vim
Always remove intermediate containers, even after unsuccessful builds. The default is false.

デフォルトはfalse。trueにするとビルド失敗後に、作成された中間コンテナを削除する。

--no-cache=true|false

vim
Do not use cache when building the image. The default is false.

デフォルトはfalse。trueにするとbuild時にcacheを使用しない。
※docker build は通常imageを作成した時に、コマンドの結果をcacheに格納し、次回以降おなじbuildの同じコマンドが実行された場合には、cacheのデータを使用する。

※注意:yum updateなどのコマンドは、取得したタイミングのupdate内容がcacheに残っているため、cacheを利用すると最新ではない可能性がある

--help

vim
Print usage statement

ヘルプ

--pull=true|false

vim
Always attempt to pull a newer version of the image. The default is false.

デフォルトはfalse。trueにすると、dockerfile内のFROM句で指定したベースイメージの最新を毎回取得する。(base/latestを取得する)

-q, --quiet=true|false

vim
Suppress the verbose output generated by the containers. The default is false.

デフォルトはfalse。trueにすると、コンテナで生成される冗長な出力を抑止する

--rm=true|false

vim
Remove intermediate containers after a successful build. The default is true.

デフォルトはtrue。ビルド成功後中間コンテナを削除する

-t, --tag=""

vim
Repository name (and optionally a tag) to be applied to the resulting image in case of success

ビルド成功後、作成されたメッセージにリポジトリ名(とオプションタグ)を付与する

--cgroup-parent=""

vim
Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist.

コンテナのcgroupsへのパスを指定します。指定されたパスが絶対パスでない場合は、initプロセスの cgroupsのパスからの相対パスと見なされます。cgroupsが存在しない場合は、作成されます。

148
111
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
148
111