构建 docker 镜像添加环境变量

Dockerfile

FROM alpine:latest
ARG tag1
ARG tag2
ENV TAG1=${tag1}
ENV TAG2=${tag2}

docker build

docker build -t test_env --build-arg tag1="aaa" --build-arg tag2="bbb" .

参考文档

  • https://docs.docker.com/engine/reference/commandline/build/#set-build-time-variables—build-arg
  • https://docs.docker.com/engine/reference/builder/#arg
  • https://docs.docker.com/engine/reference/builder/#env

以上

你可能感兴趣的:(docker,ARG,ENV,docker,build)