Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning if single quotes are used in a JSON array #28

Closed
rcjsuen opened this issue Mar 17, 2018 · 3 comments
Closed

Add warning if single quotes are used in a JSON array #28

rcjsuen opened this issue Mar 17, 2018 · 3 comments
Assignees

Comments

@rcjsuen
Copy link
Owner

rcjsuen commented Mar 17, 2018

As reported in moby/moby#5701 and microsoft/vscode-docker#238, it seems like using single quotes in a JSON array for CMD, ENTRYPOINT, and RUN instructions can cause very cryptic failures when trying to build the Docker image. We should add a warning about this case. We can't make it an error because the use of single quotes can be valid in a shell.

@rcjsuen
Copy link
Owner Author

rcjsuen commented Apr 4, 2018

SHELL has strict checks as it can only be written in JSON format. The other instructions listed below can have its arguments optionally written in JSON format and so they are the ones that need to be checked by this new validation rule.

  • ADD
  • CMD
  • COPY
  • ENTRYPOINT
  • RUN
  • VOLUME

@rcjsuen rcjsuen self-assigned this Apr 6, 2018
@rcjsuen rcjsuen closed this as completed in 58dd3f4 Apr 7, 2018
@AnalyzePlatypus
Copy link

Awesome!

@rcjsuen
Copy link
Owner Author

rcjsuen commented Apr 8, 2018

@AnalyzePlatypus Thank you for the bug report! Feel free to give it a try if you wish.

$ cat Dockerfile
FROM alpine
CMD ['/bin/bash', 'echo', 'mysteriously fails']

$ docker run -v `pwd`/Dockerfile:/Dockerfile rcjsuen/dockerfile-utils lint /Dockerfile
Unable to find image 'rcjsuen/dockerfile-utils:latest' locally
latest: Pulling from rcjsuen/dockerfile-utils
605ce1bd3f31: Pull complete
f10758dcda1f: Pull complete
4cbe43d669e5: Pull complete
442a9925b792: Pull complete
5e0a6f5380bd: Pull complete
025909e442bf: Pull complete
39e410f34e60: Pull complete
Digest: sha256:aefa214aafa47ecb2fc1c4ed77a1d81bb75610acbf59e8ed9b1c2d94b1db028f
Status: Downloaded newer image for rcjsuen/dockerfile-utils:latest
Line: 2
CMD ['/bin/bash', 'echo', 'mysteriously fails']
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning: Instruction written as a JSON array but is using single quotes instead of double quotes

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

No branches or pull requests

2 participants