在我的 docker 文件中
# [s] in brackets to allow for the folder to not exist
COPY package.json node_module[s]/ ./
受到Dockerfile中的条件复制/添加的启发?。当我跑步时
DOCKER_BUILDKIT=0 docker compose build
无论是否存在
node_modules
,一切都正常。
当我跑步时
DOCKER_BUILDKIT=1 docker compose build
如果
node_modules
不存在,则一切正常。但如果它确实存在,那么我会得到这个完全无意义的错误:
failed to solve: failed to compute cache key: failed to calculate checksum of ref cf300a02-19ca-4a07-951f-080a0c0ef0b0::x8jv3lm9rqctbwfjb6qsha2kk: "/usr/bin/python3": not found
/usr/bin/python3
是根本不是我想要复制的。
$ docker -v
Docker version 24.0.7, build 24.0.7-0ubuntu2~22.04.1
我怎样才能让事情正常运转?
在写这个问题的时候,我发现“
"/usr/bin/python3": not found
”实际上是问题所在。我的 node_modules
中碰巧有符号链接
$ find ./node_modules/ -type l -ls | grep python
53108278 0 lrwxrwxrwx 1 user user 16 Sep 10 2023 ./node_modules/cpu-features/build/node_gyp_bins/python3 -> /usr/bin/python3
53108265 0 lrwxrwxrwx 1 user user 16 Sep 10 2023 ./node_modules/ssh2/lib/protocol/crypto/build/node_gyp_bins/python3 -> /usr/bin/python3
我猜 buildkit 改变了符号链接的处理方式,但未能提供足够的错误消息。 (我仍然通常使用
DOCKER_BUILDKIT=0
,因为输出更有用)。