docker / docker/cli

Explain that single quotes will escape everything in LABELs

Open
#692 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/builder kind/docs
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

Description
Using variables in single quotes of a LABEL instruction will cause it to not be expanded. This seems to be the expected behaviour from shells that has been translated into a Dockerfile. Alright, no big deal I suppose. But can we get this mentioned in the builder.md file?

Steps to reproduce the issue:

FROM scratch
ARG arg="abc"
ENV env="def"
LABEL abc='$arg'
LABEL def='$env'
$ docker build .
Sending build context to Docker daemon  1.571MB
Step 1/5 : FROM scratch
 --->
Step 2/5 : ARG arg="abc"
 ---> Running in ba8af669a2d2
 ---> f88b7049ae5e
Removing intermediate container ba8af669a2d2
Step 3/5 : ENV env "def"
 ---> Running in 0c185027596d
 ---> 9ced66814d7a
Removing intermediate container 0c185027596d
Step 4/5 : LABEL abc '$arg'
 ---> Running in 28d867245926
 ---> ff415136967f
Removing intermediate container 28d867245926
Step 5/5 : LABEL def '$env'
 ---> Running in 05e1fca053cb
 ---> 9d3437a0c8cc
Removing intermediate container 05e1fca053cb
Successfully built 9d3437a0c8cc
$ docker inspect 9d3437a0c8cc
"Labels": {
  "abc": "$arg",
  "def": "$env"
}

Output of docker version:

$ docker --version
Docker version 17.09.0-ce, build afdb6d4

Output of docker info:

$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 4
Server Version: 17.09.0-ce
Storage Driver: overlay2
 Backing Filesystem: xfs
 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 logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-96-generic
Operating System: Alpine Linux v3.6 (containerized)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 31.4GiB
Name: node1
ID: O7HP:AR4C:YRH3:DNIQ:HGF4:5FRX:VHTJ:73Z6:DZ4J:LDDH:VTOF:3732
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 18
 Goroutines: 27
 System Time: 2017-11-13T21:46:57.229067696Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.1
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open docs/reference/builder.md and review the LABEL instruction documentation alongside the provided single-quoted examples. Explain that variables inside single quotes are not expanded, then verify that the wording accurately matches the demonstrated docker build and inspect behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.