在处理特定项目时,我偶然发现了这一点,但是当我尝试在Docker中复制特定文件夹时出现了一些问题。这是问题的MWE:
Dockerfile
FROM gcc:7.3 as src
FROM node:12.9.0-buster-slim
RUN ls /
COPY --from=src /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
RUN ls /
ENTRYPOINT ["echo", "Hello world!"]
使用docker build --no-cache -t test-docker:local .
构建将产生以下输出:
Sending build context to Docker daemon 2.048kB
Step 1/6 : FROM gcc:7.3 as src
---> c73fc3aa8615
Step 2/6 : FROM node:12.9.0-buster-slim
---> 3b17aa213191
Step 3/6 : RUN ls /
---> Running in 3d0cb0b2afaa
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var
Removing intermediate container 3d0cb0b2afaa
---> 9663b22e0ee6
Step 4/6 : COPY --from=src /lib/x86_64-linux-gnu/ /lib/x86_64-linux-gnu/
---> 509e345af40f
Step 5/6 : RUN ls /
---> Running in 01952c9982d4
The command '/bin/sh -c ls /' returned a non-zero code: 139
我很好奇为什么Dockerfile命令首先失败。是由于文件夹的特殊含义,不允许我以某种方式复制文件夹吗?