python3.*-在 docker build 中安装 pip 期间出现错误 - PermissionError - 使用 VScode

2024-01-24

使用 python3.8-minimal 和 python3.10-minimal 的 20.04 和 22.04 docker 镜像会发生这种情况(分别是我尝试过的唯一镜像)。图像正在 VScode 中构建。 问题发生在

apt install pip

output:

    ente#0 136.4 Preparing to unpack .../libpython3.8-minimal_3.8.10-0ubuntu1~20.04.4_amd64.deb ...

#0 136.4 Unpacking libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04.4) ...

#0 136.5 Selecting previously unselected package python3.8-minimal.

#0 136.5 Preparing to unpack .../python3.8-minimal_3.8.10-0ubuntu1~20.04.4_amd64.deb ...

#0 136.5 Unpacking python3.8-minimal (3.8.10-0ubuntu1~20.04.4) ...

#0 136.6 Setting up libpython3.8-minimal:amd64 (3.8.10-0ubuntu1~20.04.4) ...

#0 136.6 Setting up python3.8-minimal (3.8.10-0ubuntu1~20.04.4) ...

#0 136.7 Traceback (most recent call last):

#0 136.7   File "/usr/lib/python3.8/py_compile.py", line 215, in <module>

#0 136.7     sys.exit(main())

#0 136.7   File "/usr/lib/python3.8/py_compile.py", line 207, in main

#0 136.7     compile(filename, doraise=True)

#0 136.7   File "/usr/lib/python3.8/py_compile.py", line 172, in compile

#0 136.7     importlib._bootstrap_external._write_atomic(cfile, bytecode, mode)

#0 136.7   File "<frozen importlib._bootstrap_external>", line 186, in _write_atomic

#0 136.7 PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.8/__pycache__/__future__.cpython-38.pyc.140212054232736'

#0 136.7 dpkg: error processing package python3.8-minimal (--configure):

#0 136.7  installed python3.8-minimal package post-installation script subprocess returned error exit status 1

#0 136.7 Errors were encountered while processing:

#0 136.7  python3.8-minimal

我尝试构建一个没有任何内容的容器并从容器内部运行命令。

sudo apt install pip

and

sudo apt install python3-pip

还是失败

那么输出是:

 erl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
debconf: delaying package configuration, since apt-utils is not installed
Setting up python3.8-minimal (3.8.10-0ubuntu1~20.04.4) ...
Traceback (most recent call last):
  File "/usr/lib/python3.8/py_compile.py", line 215, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/py_compile.py", line 207, in main
    compile(filename, doraise=True)
  File "/usr/lib/python3.8/py_compile.py", line 172, in compile
    importlib._bootstrap_external._write_atomic(cfile, bytecode, mode)
  File "<frozen importlib._bootstrap_external>", line 186, in _write_atomic
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.8/__pycache__/__future__.cpython-38.pyc.139810610523808'
dpkg: error processing package python3.8-minimal (--configure):
 installed python3.8-minimal package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 python3.8-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

这似乎无法在其他电脑上重现

最小 Dockerfile 失败:

FROM ubuntu:20.04

RUN apt update -y && apt upgrade -y

RUN apt install pip -y

任何帮助将不胜感激


正如其他人提到的,在docker中使用overlay2存储后端时似乎会发生问题。这并不限于快照,但如果您使用快照,那么它是默认配置。要在 docker 的快照安装版本中更改此设置:

  • 编辑 /var/snap/docker/current/config/daemon.json 并替换 存储驱动程序的“overlay2”和“vfs”
  • run sudo snap restart docker
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python3.*-在 docker build 中安装 pip 期间出现错误 - PermissionError - 使用 VScode 的相关文章

随机推荐