How to prevent field splitting when using ENV variables in Docker ENTRYPOINT

This post is also available on my blog.

By default, variables will be split by space characters. This is not what you want if you have a message that contains spaces for example.

To prevent this, the variable may be surrounded by quotation marks. If you’re using the exec form in the ENTRYPOINT. quotation marks can be escaped with backslashes.

Let's see an example:

Takes two variables (message and version) and prints them.


You will see the following output if you build and run it:

If you don’t use spaces around the MESSAGE variable in the ENTRYPOINT. You will see this output:


PHP Software & DevOps Engineer. Moved to