Dockerfile RUN

语法

RUN cmd

例如: RUN apt-get update

RUN "executable", "param1", "param2"

例如:RUN "apt-get","update"

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

bash 复制代码
FROM redis
RUN apt-get -y update &&\
 apt-get -y upgrade &&\
 apt-get install -y vim &&\
 apt-get install -y fish
bash 复制代码
下面的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
相关推荐
lichenyang4531 小时前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang4531 小时前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4531 小时前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4531 小时前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
Patrick_Wilson5 天前
从「改个端口」到 502:Next.js on k8s 的容器端口、Service 映射与 env 覆盖
docker·kubernetes·next.js
Suroy5 天前
DockerView-Go:用 Go 写一个终端 Docker 监控工具,顺便做了个 Web 仪表盘
docker
云恒要逆袭5 天前
运行你的第一个Docker容器
后端·docker·容器
宋均浩6 天前
# Docker 镜像瘦身实战:从 1.2G 到 80MB 的五个优化步骤
ci/cd·docker
程序员老赵7 天前
10 分钟部署 OpenCode:Docker 一键安装,浏览器打开就能用 AI 写代码(附完整命令与排错)
docker·容器·ai编程
WangMingHua1117 天前
LM Studio Docker 部署——本地大模型一键启动
docker