我理解图层和牛和unionfs等的基本概念。我一直听到
Dockerfile中的每一行都会创建一个新图层
所以我做了一些实验。这是我的Dockerfile:
FROM davidjfelix/python3.5
RUN mkdir -p /code/server
ADD app.py /code
ADD ./server /code/server
ADD requirements.txt /code/
WORKDIR /code
RUN pip3 install -r requirements.txt
VOLUME /stuff
EXPOSE 7000
CMD ["/usr/local/bin/python", "-u", "app.py"]
所以它是基于Python3.5图像的新图像。创建新图像后,我在两个图像上都docker inspect
,发现新图像中的图层比<3>
"RootFS": {
"Type": "layers",
"Layers": [
"sha256:6c3eb4525275f7040b8e3fbc846425ef934e1d44412d01cb37dc907d7d16e468",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:19f5e5ea72d6119ff25fb7bd45974cc108ae0bdc42bdeef1d805e1114502fe70",
"sha256:cd55733e01aec60a4e2c644f5bbf14b4c543cc1bce38f1757e8dda457d19de28",
"sha256:b8d8fe2d495aefca232e1a5b683b5ba3dce0661da29adc97e492274f31d9f4b6",
"sha256:258951e4bcc601a96055b0bf6e230a298f27c44bd9838ab9fbe4fb4824f3f1ca",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:b421868bee11843b136d6051d5f497c6d47fa67d2d5895853c6055ef5c75ef5a",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef",
"sha256:26f874482e486b9989aba19b50a9b8308cb29a8dc6d3d8da00d05373cb0bad1e",
"sha256:4a3ef76df24253c3034313384494e3f8136c2580d2ddf423aaeed9297f83b22d",
"sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef"
]
}
如果开头的陈述错了?
答案 0 :(得分:2)
此处显示的图层是 filesystem 图层
Dockerfile
,WORKDIR
,VOLUME
,EXPOSE
等CMD
指令不会更改FS。
docker history
会显示这些命令,但不显示docker inspect
请参阅&#34; Show Layers of Docker Image&#34;