Be aware of the quotes in your Dockerfile

Tl;dr: Don't use single quotes `'` in your Dockerfile instructions, but use double quotes `"`.

This is something interesting I discovered today by doing the following:

I ran `docker run --rm -it ruby` and I get the [official ruby image default CMD]( command executed (which is an `irb` prompt).

Then I replaced the CMD command by the same command in this simple Dockerfile:

FROM ruby
CMD ['irb']

But this ended up with an error about `irb not found` (the exact output is this `/bin/sh: 1: [irb]: not found`).

I had never heard about single quote being erroneous...

But.. This was my fault not *RTFMing* enough...

It is indeed precised in the [Dockerfile reference]( *(and also applicable to other commands like RUN, CMD, LABEL, ENV, ENTRYPOINT and VOLUME)*:

>**Note**: The *exec* form is parsed as a JSON array, which means that you must use double-quotes (“) around words not single-quotes (‘).

4 thoughts on “Be aware of the quotes in your Dockerfile”

  1. Also, if you’re using Jenkins, don’t try to add more than one space after “FROM“ to align things.

    Container builds will fail.

    (The 100 lines of stack trace won’t point out a plug-in forgot to trim a string)


Leave a Comment