mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-09 07:24:04 +08:00
43 lines
2.7 KiB
HTML
43 lines
2.7 KiB
HTML
<h1>Docker build 命令</h1>
|
||
<p><strong>docker build </strong> 命令用于使用 Dockerfile 创建镜像。</p>
|
||
<h3>语法</h3>
|
||
<pre>docker build [OPTIONS] PATH | URL | -</pre>
|
||
<p>OPTIONS说明:</p>
|
||
<ul>
|
||
<li><p><strong>--build-arg=[] :</strong>设置镜像创建时的变量;</p></li>
|
||
<li><p><strong>--cpu-shares :</strong>设置 cpu 使用权重;</p></li>
|
||
<li><p><strong>--cpu-period :</strong>限制 CPU CFS周期;</p></li>
|
||
<li><p><strong>--cpu-quota :</strong>限制 CPU CFS配额;</p></li>
|
||
<li><p><strong>--cpuset-cpus :</strong>指定使用的CPU id;</p></li>
|
||
<li><p><strong>--cpuset-mems :</strong>指定使用的内存 id;</p></li>
|
||
<li><p><strong>--disable-content-trust :</strong>忽略校验,默认开启;</p></li>
|
||
<li><p><strong>-f :</strong>指定要使用的Dockerfile路径;</p></li>
|
||
<li><p><strong>--force-rm :</strong>设置镜像过程中删除中间容器;</p></li>
|
||
<li><p><strong>--isolation :</strong>使用容器隔离技术;</p></li>
|
||
<li><p><strong>--label=[] :</strong>设置镜像使用的元数据;</p></li>
|
||
<li><p><strong>-m :</strong>设置内存最大值;</p></li>
|
||
<li><p><strong>--memory-swap :</strong>设置Swap的最大值为内存+swap,"-1"表示不限swap;</p></li>
|
||
<li><p><strong>--no-cache :</strong>创建镜像的过程不使用缓存;</p></li>
|
||
<li><p><strong>--pull :</strong>尝试去更新镜像的新版本;</p></li>
|
||
<li><p><strong>--quiet, -q :</strong>安静模式,成功后只输出镜像 ID;</p></li>
|
||
<li><p><strong>--rm :</strong>设置镜像成功后删除中间容器;</p></li>
|
||
<li><p><strong>--shm-size :</strong>设置/dev/shm的大小,默认值是64M;</p></li>
|
||
<li><p><strong>--ulimit :</strong>Ulimit配置。</p></li>
|
||
<li><p><strong>--tag, -t:</strong> 镜像的名字及标签,通常 name:tag 或者 name 格式;可以在一次构建中为一个镜像设置多个标签。</p></li>
|
||
<li><p><strong>--network:</strong> 默认 default。在构建期间设置RUN指令的网络模式</p></li>
|
||
</ul>
|
||
<h3>实例</h3>
|
||
<p>使用当前目录的 Dockerfile 创建镜像,标签为 runoob/ubuntu:v1。</p>
|
||
<pre>docker build -t runoob/ubuntu:v1 . </pre>
|
||
<p>使用URL <strong>github.com/creack/docker-firefox</strong> 的 Dockerfile 创建镜像。
|
||
|
||
</p><pre>docker build github.com/creack/docker-firefox</pre>
|
||
<p>也可以通过 -f Dockerfile 文件的位置:</p>
|
||
<pre>$ docker build -f /path/to/a/Dockerfile .</pre>
|
||
<p>在 Docker 守护进程执行 Dockerfile 中的指令前,首先会对 Dockerfile 进行语法检查,有语法错误时会返回:</p>
|
||
<pre>$ docker build -t test/myapp .
|
||
|
||
Sending build context to Docker daemon 2.048 kB
|
||
Error response from daemon: Unknown instruction: RUNCMD</pre>
|
||
|