我想将WORKDIR /opt/app替换为全局ARG,但它不起作用:
ARG BUILD_IMAGE=maven:3.8.4-eclipse-temurin-11
ARG APP=/opt/app
FROM $BUILD_IMAGE as dependencies
#WORKDIR /opt/app #this would pass!
WORKDIR ${APP}结果:
Error response from daemon: cannot normalize nothing
Failed to deploy Dockerfile': Can't retrieve image ID from build stream为什么?
发布于 2022-03-24 11:26:04
ARGs的作用域被限定到舞台,或者在文件顶部定义的from行。因此,在FROM行之后定义ARG,最好是在使用它之前(为了缓存效率)。
# define top level args used in FROM lines here
ARG BUILD_IMAGE=maven:3.8.4-eclipse-temurin-11
FROM $BUILD_IMAGE as dependencies
# define your args scoped within the stage after the FROM for that stage
ARG APP=/opt/app
WORKDIR ${APP}如果您想设置一次arg值并重用它,则如下所示:
# define top level args used in FROM lines here
ARG BUILD_IMAGE=maven:3.8.4-eclipse-temurin-11
# the top section can also define the default value of an arg that is defined elsewhere
ARG APP=/opt/app
FROM $BUILD_IMAGE as dependencies
# define your args scoped within the stage after the FROM for that stage
ARG APP
WORKDIR ${APP}https://stackoverflow.com/questions/71601512
复制相似问题