Skip to content

let parent ENV and child ARG have the same name #34494

@andre-richter

Description

@andre-richter

Description

I have a parent Dockerfile:

FROM debian

ARG IMAGE_NAME
ENV IMAGE_NAME=$IMAGE_NAME

and a child Dockerfile:

FROM parent

ARG IMAGE_NAME
ENV IMAGE_NAME=$IMAGE_NAME

RUN echo $IMAGE_NAME

I build with:

docker build --build-arg IMAGE_NAME=parent -t parent -f Dockerfile.parent .
docker build --build-arg IMAGE_NAME=child -t child -f Dockerfile.child .

Steps to reproduce the issue:

  1. Use files shown before and build

Describe the results you received:

The RUN command in the second container outputs parent, because the ARG IMAGE_NAME is ignored, since it exists as an ENV in the parent file.

Describe the results you expected:

Changing the name of ARG in the second container resolves this problem, but is this a bug or a feature? I would suspect ARG IMAGE_NAME to overload $IMAGE_NAME at least for the scope of the child Dockerfile.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:23:31 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.0-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:19:04 2017
 OS/Arch:      linux/amd64
 Experimental: false

Output of docker info:

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 69
Server Version: 17.06.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 46
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-89-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 31.25GiB
Name: precision
ID: Q2ND:NM4A:LDKO:MW5R:4MJA:2ERU:MC67:ZZUY:D66G:PBFA:23O3:YCOC
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Additional environment details (AWS, VirtualBox, physical, etc.):

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions