加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Docker,一个或多个未消耗的构建参数

发布时间:2020-12-16 03:43:58 所属栏目:安全 来源:网络整理
导读:我正在尝试使用自定义环境变量构建Oracle WebLogic Docker镜像 $docker build -t 12213-domain --build-arg ADMIN_PORT=8888 --build-arg ADMIN_PASSWORD=wls . 但是我在构建日志中收到以下警告 [Warning] One or more build-args [ADMIN_PASSWORD ADMIN_POR

我正在尝试使用自定义环境变量构建Oracle WebLogic Docker镜像

$docker build -t 12213-domain --build-arg ADMIN_PORT=8888 --build-arg ADMIN_PASSWORD=wls .

但是我在构建日志中收到以下警告

[Warning] One or more build-args [ADMIN_PASSWORD ADMIN_PORT] were not consumed

这是我正在尝试构建的图像的Dockerfile

#Copyright (c) 2014-2017 Oracle and/or its affiliates. All rights reserved.
#
#Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
#
# ORACLE DOCKERFILES PROJECT
# --------------------------
# This Dockerfile extends the Oracle WebLogic image by creating a sample domain.
#
# Util scripts are copied into the image enabling users to plug NodeManager 
# automatically into the AdminServer running on another container.
#
# HOW TO BUILD THIS IMAGE
# -----------------------
# Put all downloaded files in the same directory as this Dockerfile
# Run: 
#      $sudo docker build -t 12213-domain
#
# Pull base image
# ---------------
FROM oracle/weblogic:12.2.1.3-developer

# Maintainer
# ----------
MAINTAINER Monica Riccelli 

我正在Windows上运行docker-toolbox,而docker版本则是

$docker --version
Docker version 18.03.0-ce,build 0520e24302
最佳答案
ARG

ARG 

The ARG instruction defines a variable that users can pass at
build-time to the builder with the docker build command using the
–build-arg = flag. If a user specifies a build argument that was not defined in the Dockerfile,the build outputs a
warning.

[Warning] One or more build-args [foo] were not consumed.

https://docs.docker.com/engine/reference/builder/#arg

使用ARG变量

You can use an ARG or an ENV instruction to specify variables that are
available to the RUN instruction. Environment variables defined using
the ENV instruction always override an ARG instruction of the same
name. Consider this Dockerfile with an ENV and ARG instruction.

Unlike an ARG instruction,ENV values are always persisted in the
built image. Consider a docker build without the –build-arg flag:

ARG仅在构建Docker镜像(RUN等)时可用,而不是在创建图像并从中启动容器(ENTRYPOINT,CMD)之后.您可以使用ARG值来设置ENV值以解决此问题.

所以你需要做这样的事情

# Assign any default value to avoid any error. do not worry your build flag will override this.

    ARG ADMIN_PORT=some_default_value 

    ENV ADMIN_PORT=${ADMIN_PORT}

https://vsupalov.com/docker-arg-env-variable-guide/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读