我有一个装有 ubuntu 22.04 lts 的容器,当我需要安装需要 pyhton3.x-minimal 的包或程序时,它会抛出权限被拒绝错误,我也是 root。这很奇怪,但我无法解决它。
这是程序安装程序
root@c0f46f619a6c:/var/www/html#apt-get install systemd
安装时会抛出以下消息
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
dmsetup gir1.2-glib-2.0 libcryptsetup12 libdevmapper1.02.1 libgirepository-1.0-1 libip4tc2 libjson-c5 libkmod2 libmpdec3 libpython3-stdlib libpython3.10-minimal libpython3.10-stdlib
networkd-dispatcher python3 python3-dbus python3-gi python3-minimal python3.10 python3.10-minimal systemd-timesyncd
Suggested packages:
iw | wireless-tools python3-doc python3-tk python3-venv python-dbus-doc python3.10-venv python3.10-doc binutils binfmt-support systemd-container libfido2-1 libtss2-esys-3.0.2-0
libtss2-mu0 libtss2-rc0 policykit-1
The following NEW packages will be installed:
dmsetup gir1.2-glib-2.0 libcryptsetup12 libdevmapper1.02.1 libgirepository-1.0-1 libip4tc2 libjson-c5 libkmod2 libmpdec3 libpython3-stdlib libpython3.10-minimal libpython3.10-stdlib
networkd-dispatcher python3 python3-dbus python3-gi python3-minimal python3.10 python3.10-minimal systemd systemd-timesyncd
0 upgraded, 21 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.2 MB of archives.
After this operation, 41.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-minimal amd64 3.10.6-1~22.04.2ubuntu1 [810 kB]
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3.10-minimal amd64 3.10.6-1~22.04.2ubuntu1 [2263 kB]
Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 python3-minimal amd64 3.10.6-1~22.04 [24.3 kB]
Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libmpdec3 amd64 2.5.1-2build2 [86.8 kB]
Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10-stdlib amd64 3.10.6-1~22.04.2ubuntu1 [1831 kB]
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpython3.10-minimal:amd64.
(Reading database ... 19257 files and directories currently installed.)
Preparing to unpack .../libpython3.10-minimal_3.10.6-1~22.04.2ubuntu1_amd64.deb ...
Unpacking libpython3.10-minimal:amd64 (3.10.6-1~22.04.2ubuntu1) ...
Selecting previously unselected package python3.10-minimal.
Preparing to unpack .../python3.10-minimal_3.10.6-1~22.04.2ubuntu1_amd64.deb ...
Unpacking python3.10-minimal (3.10.6-1~22.04.2ubuntu1) ...
Setting up libpython3.10-minimal:amd64 (3.10.6-1~22.04.2ubuntu1) ...
Setting up python3.10-minimal (3.10.6-1~22.04.2ubuntu1) ...
[Errno 13] Permission denied: '/usr/lib/python3.10/__pycache__/__future__.cpython-310.pyc.140322885704192'dpkg: error processing package python3.10-minimal (--configure):
installed python3.10-minimal package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
python3.10-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)
我尝试更改一些执行和写入权限,但问题仍然存在
答案1
我遇到了同样的问题,解决方案是改变我在计算机上运行 docker 的方式,因为显然在 Ubuntu 22.04 中使用 snap 安装 docker 的方式存在一个错误,从而产生了这个问题。
此主题中的更多信息:https://forums.docker.com/t/bug-on-apt-install-permission-denied/100196
我修复此问题所遵循的具体步骤如下:https://forums.docker.com/t/bug-on-apt-install-permission-denied/100196/9
答案2
就我而言,以下操作顺序有所帮助:
sudo systemctl daemon-reload
sudo systemctl restart docker
sudo systemctl restart docker.socket docker.service
docker rm -f <container id> // remove all containers which can cause your problem
- 重试docker容器构建