Dockerfile RUN

语法

RUN cmd
例如: RUN apt-get update
RUN [“executable”, “param1”, “param2”]
例如:RUN [“apt-get”,“update”]

请注意,每个 RUN 指令都会创建一个新的镜像层,因此在 Dockerfile 中使用 RUN 指令时,要注意将多个命令合并到一个 RUN 指令中以减小镜像的层数,这可以提高构建性能并减小镜像大小。例如:

FROM redis
RUN apt-get -y update &&\
 apt-get -y upgrade &&\
 apt-get install -y vim &&\
 apt-get install -y fish

Dockerfile RUN_第1张图片

下面的4个run会给镜像多增加4层layer
FROM redis
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install -y vim
RUN apt-get install -y fish

Dockerfile RUN_第2张图片

你可能感兴趣的:(docker,docker)