问题
在docker(ubuntu 22.04)中运行apt update
报错:
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB]
Get:2 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Err:2 http://security.ubuntu.com/ubuntu jammy-security InRelease
Couldn't create temporary file /tmp/apt.conf.XXLh0Z for passing config to apt-key
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Couldn't create temporary file /tmp/apt.conf.Y0klwg for passing config to apt-key
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Err:3 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Couldn't create temporary file /tmp/apt.conf.FVVrOZ for passing config to apt-key
Get:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease [127 kB]
Err:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Couldn't create temporary file /tmp/apt.conf.2CBY68 for passing config to apt-key
Reading package lists... Done
W: GPG error: http://security.ubuntu.com/ubuntu jammy-security InRelease: Couldn't create temporary file /tmp/apt.conf.XXLh0Z for passing config to apt-key
E: The repository 'http://security.ubuntu.com/ubuntu jammy-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy InRelease: Couldn't create temporary file /tmp/apt.conf.Y0klwg for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu jammy InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy-updates InRelease: Couldn't create temporary file /tmp/apt.conf.FVVrOZ for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu jammy-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy-backports InRelease: Couldn't create temporary file /tmp/apt.conf.2CBY68 for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu jammy-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
解决方案:
检查/tmp目录的权限:ls -ld /tmp
drwxrwxr-x 2 1007 1008 4096 Jan 11 2024 /tmp
修改权限:chmod 1777 /tmp
(在docker中默认有root权限,所以不需要sudo)
drwxrwxrwt 1 1007 1008 4096 Jan 11 2024 /tmp
再次执行apt update
就不报错了。