2017-10-02 18:48
浏览 173


I have a Go application that I build into a binary and distribute as a Docker image.

Currently, I'm using ubuntu as my base image, but this causes an issue where if a user tries to use a Timezone other than UTC or their local timezone, they get an error stating:

pod error: panic: open /usr/local/go/lib/time/ no such file or directory

This error is caused because the LoadLocation package in Go requires that file.

I can think of two ways to fix this issue:

  1. Continue using the ubuntu base image, but in my Dockerfile add the commands: RUN apt-get install -y tzdata

  2. Use one of Golang's base images, eg. golang:1.7.5-alpine.

What would be the recommended way? I'm not sure if I need to or should be using a Golang image since this is the container where the pre-built binary runs. My understanding is that Golang images are good for building the binary in the first place.

图片转代码服务由CSDN问答提供 功能建议

我有一个Go应用程序,该应用程序已构建为二进制文件并作为Docker映像分发。</ p>

当前,我正在使用 ubuntu </ code>作为我的基本映像,但这会导致一个问题:如果用户尝试使用UTC或其本地时区以外的时区,则会收到错误消息 说明:</ p>

 </ code> </  pre> 

此错误是由于Go中的 LoadLocation 包引起的 需要该文件。</ p>

我可以想到两种方法来解决此问题:</ p>

  1. 继续使用 ubuntu </ code>基本映像,但在我的Dockerfile中添加命令: RUN apt-get install -y tzdata </ code> </ p> </ p> </ li>

  2. 使用一个 Golang的基本图像,例如 golang:1.7.5-alpine </ code>。</ p> </ li> </ ol>

    推荐的方法是什么? 我不确定是否需要或应该使用Golang映像,因为这是运行预构建二进制文件的容器。 我的理解是Golang图像最适合首先构建二进制文件。</ p> </ div>

4条回答 默认 最新

相关推荐 更多相似问题