#(nop)在泊坞历史中意味着什么?

use*_*834 14 docker

#(nop)上市时前缀是什么意思docker history

$ docker history swarm
IMAGE               CREATED             CREATED BY   
c54bba046158        9 days ago          /bin/sh -c #(nop) CMD ["--help"]
Run Code Online (Sandbox Code Playgroud)

Rot*_*ots 12

NOP代表"无操作".

Docker为每一层运行一个shell.除了RUN命令之外,Dockerfile中的所有docker命令(或层)在历史记录中显示为空命令或已注释掉的shell命令.该#标志标志着评论的开始,之后的任何内容都将被跳过/bin/sh.同样,如果您输入终端:

user@machine $ echo hello world
hello world
user@machine $ #But none of these lines starting with # do anything
user@machine $ #echo hello world
Run Code Online (Sandbox Code Playgroud)

RUN命令不需要由shell解释,而是由内部的docker处理.

如果RUN先前已运行相同的命令,则层高速缓存可以使用历史(包括非命令)来跳过处理.

  • 我花了一段时间才理解这一点,但我认为它的意思是 `docker history` 命令回放了一个 `/bin/sh` 日志记录文件,以及不需要像 `ADD` 和 `CMD` 这样的 docker 命令要执行的 shell(大概是使用其他工具完成的工作)作为注释回显到 shell,这样它们仍然会显示在日志记录中,因此“docker history”命令......我想...... .. (2认同)