RUN command in Dockerfile

admin 2021-09-07 14:38:58 0 0 Docker 143 已编辑 复制链接

There are two patterns to use RUN command when composing Dockerfile:


RUN <command>

RUN ["executable", "param1", "param2"]


The first one based on shell pattern, and the second one is using exec pattern.

The shell pattern using "/bin/sh" as default shell.

But the second can specify whatever shell you like, like RUN ["/bin/bash", "-c", "command"]


And you can also merge multiple commands into single one by concatenating them by &&, this will reduce redundant intermediate image layers.


评论(0)

    还没有评论,快来抢沙发吧!