Dockerfile编码是哪个?

Which is the Dockerfile encoding?

定义我的 Dockerfile 我到了这一行:

...
MAINTAINER Ramón <ramon@example.com>
...

我应该使用哪种编码来保存这个文件?

我应该转义非 ASCII 字符吗?

考虑到Docker is done in Go, and Go has native support for utf-8,最好保存一个直接用UTF-8编码的Dockerfile。

这样,所有 个字符(ASCII 或非 ASCII)都受支持。

参见“Dealing with encodings in Go”。

Even though Go has good support for UTF-8 (and minimal support for UTF-16), it has no built-in support for any other encoding.
If you have to use other encodings (e.g. when dealing with user input), you have to use third party packages, like for example go-charset.

这里Dockerfile最好直接UTF-8编码。


2016 年 7 月更新,docker 1.12-rc5 添加:

  • PR 23372: 支持 parseWords 中的 unicode 字符
  • PR 23234: 跳过 Dockerfile 中的 UTF-8 BOM 字节和 .docker如果存在则忽略

您需要正确设置语言环境,去掉重音,用基本的 docker run -it container env 检查编码,然后输入正确的编码,"Bible" 就是 http://jaredmarkell.com/docker-and-locales/