Docker 镜像缺少 /tmp?

jjm*_*elo 4 debian docker dockerfile

我试图基于这个基于 Debian Stretch 的镜像构建一个镜像,但在运行时不断出现此类错误apt-get update

W: GPG error: http://security.debian.org stretch/updates InRelease: Couldn't create temporary file /tmp/apt.conf.FNG6R8 for passing config to apt-key
Run Code Online (Sandbox Code Playgroud)

刚刚添加后就解决了这个问题

mkdir /tmp && chmod 777 /tmp \
Run Code Online (Sandbox Code Playgroud)

到 Dockerfile RUN。但问题是,Docker 镜像是否缺少 tmp 文件?只有基于 的图像才是这种情况吗buildpack-deps:stretch-scm?有没有比手动创建/tmp目录更好的方法来处理这个问题?

小智 5

我遇到了与您相同的错误,并且按照 BMitch 的建议,在我的 Dockerfile 中添加这一层为我解决了这个问题。

RUN chmod 1777 /tmp
Run Code Online (Sandbox Code Playgroud)