apt-get update无法创建临时文件报错
报错内容如下:
Get:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease [265 kB]
Err:1 http://ports.ubuntu.com/ubuntu-ports focal InRelease
Couldn’t create temporary file /tmp/apt.conf.T7lK6i for passing config to apt-key
Get:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [114 kB]
Err:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease
Couldn’t create temporary file /tmp/apt.conf.wisI5n for passing config to apt-key
Get:3 https://apache.jfrog.io/artifactory/arrow/ubuntu focal InRelease [7291 B]
Get:4 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease [108 kB]
Err:4 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease
Couldn’t create temporary file /tmp/apt.conf.C1cEju for passing config to apt-key
Err:3 https://apache.jfrog.io/artifactory/arrow/ubuntu focal InRelease
Couldn’t create temporary file /tmp/apt.conf.D2Tv0x for passing config to apt-key
Get:5 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [114 kB]
Err:5 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease
Couldn’t create temporary file /tmp/apt.conf.raCMvC for passing config to apt-key
Reading package lists…
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal InRelease: Couldn’t create temporary file /tmp/apt.conf.T7lK6i for passing config to apt-key
E: The repository ‘http://ports.ubuntu.com/ubuntu-ports focal InRelease’ is not signed.
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease: Couldn’t create temporary file /tmp/apt.conf.wisI5n for passing config to apt-key
E: The repository ‘http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease’ is not signed.
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease: Couldn’t create temporary file /tmp/apt.conf.C1cEju for passing config to apt-key
E: The repository ‘http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease’ is not signed.
W: GPG error: https://apache.jfrog.io/artifactory/arrow/ubuntu focal InRelease: Couldn’t create temporary file /tmp/apt.conf.D2Tv0x for passing config to apt-key
E: The repository ‘https://apache.jfrog.io/artifactory/arrow/ubuntu focal InRelease’ is not signed.
W: GPG error: http://ports.ubuntu.com/ubuntu-ports focal-security InRelease: Couldn’t create temporary file /tmp/apt.conf.raCMvC for passing config to apt-key
E: The repository ‘http://ports.ubuntu.com/ubuntu-ports focal-security InRelease’ is not signed.
重点是Couldn’t create temporary file /tmp/apt.conf.T7lK6i for passing config to apt-key。
报错的原理可参考这篇博客。
解决方法
在使用apt-get update之前修改/tmp文件夹权限。
chmod 777 /tmp
在物理机上使用的直接修改就可以,像我一样在使用dockerfile创建镜像的,把这行命令加到apt-get update之前就可以。