Skip to content

No way to avoid duplicated default values if ARG needed in both FROM and RUN #2692

@dkegel-sigsci

Description

@dkegel-sigsci

Description

Steps to reproduce the issue:
Create Dockerfile with:

ARG vers=18.04
FROM ubuntu:$vers
RUN echo vers is $vers

then run

docker build .

Describe the results you received:

"vers is"

Describe the results you expected:

"vers is 18.04"

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

This took me a while to track down. The comments in #333 were helpful.

Workaround is to duplicate the ARG line
e.g.

ARG vers=18.04
FROM ubuntu:$vers
ARG vers=18.04
RUN echo vers is $vers

but this is suboptimal because somebody might forget to change both values.

Plus it's kind of counterintuitive for ARG to be "cleared" by FROM, at least to this old newbie.

Output of docker version:

Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:41:33 2020
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:49:27 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 187
 Server Version: 19.03.12
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 2.926GiB
 Name: docker-desktop
 ID: RHYA:2AXX:F4E6:HRTL:42GK:RAS4:LR6V:V5LT:MOF4:RWPX:H2TM:EVTV
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 40
  Goroutines: 52
  System Time: 2020-08-27T20:33:51.2179047Z
  EventsListeners: 3
 HTTP Proxy: gateway.docker.internal:3128
 HTTPS Proxy: gateway.docker.internal:3129
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine```

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

This is on a mac with 'brew cask install docker'.

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