Skip to content

We had some testers who found a hard to diagnose bug in Dockerfile - #11203

Merged
jessfraz merged 1 commit into
moby:masterfrom
rhatdan:Dockerfile
Mar 17, 2015
Merged

jessfraz merged 1 commit into
moby:masterfrom
rhatdan:Dockerfile

Conversation

@rhatdan

@rhatdan rhatdan commented Mar 6, 2015

Copy link
Copy Markdown
Contributor

They used single-quotes (') in the exec-form of onbuild run command
and things blew up. They asked to fix the man page to explain why.

Docker-DCO-1.1-Signed-off-by: Dan Walsh [email protected] (github: rhatdan)

They used single-quotes (') in the exec-form of onbuild run command
and things blew up.  They asked to fix the man page to explain why.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <[email protected]> (github: rhatdan)
@SvenDowideit

Copy link
Copy Markdown
Contributor

can we not fix the parser to help the user - especially as the man pages are not the first place most Docker users look?

@thaJeztah

Copy link
Copy Markdown
Member

Not sure that would be possible; the parser uses "Fuzzy logic" to decide if a CMD will be treated as JSON or Shell. If it is able to successfully parse the instruction as a JSON array, it is treated as JSON, otherwise as Shell. ['something'] is invalid JSON, but could be valid Shell

@ahmetb

ahmetb commented Mar 7, 2015

Copy link
Copy Markdown
Contributor

+1 for only accepting valid json. people then can feel free to use ' within "s

@cevich

cevich commented Mar 9, 2015

Copy link
Copy Markdown

Using "something 'something else'" and 'something "something else"' have different meanings for shells (bash at least). The first form protects something else from interpretation by the shell, but allows something to be interpreted. In the second form, the entire string is protected from shell interpretation, including "something else" (double-quotes included). So detecting based on ' is slightly faulty under some circumstances, and definitely fuzzy 😀

IMHO, it would be better to simply throw an error about bad syntax, than to assume something other than exactly what was written. Enforcing JSON syntax is fine, but trying to "out smart" users is a slippery slope toward lots more conditionals and resulting errors/bugs. However, tossing an error is faster, helps keep all Dockerfiles clean and consistent, makes testing easier, and reduces documentation required.

@jessfraz

Copy link
Copy Markdown
Contributor

LGTM

jessfraz pushed a commit that referenced this pull request Mar 17, 2015
We had some testers who found a hard to diagnose bug in Dockerfile
@jessfraz
jessfraz merged commit f4f10cf into moby:master Mar 17, 2015
@jessfraz

Copy link
Copy Markdown
Contributor

if someone makes a patch to the parser we can remove this from the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants