docker python3.x-Ubuntu更新后的最小错误[重复]

bq3bfh9z  于 2023-06-05  发布在  Docker
关注(0)|答案(1)|浏览(431)

此问题已在此处有答案

python3.*-minimal Error during pip installation in docker build - PermissionError - using VScode(2个答案)
3天前关闭。
我的应用程序运行良好。现在我想把我的服务器从Ubuntu 20迁移到新的EC2。
这个问题不仅在新的ubuntu(22)上,而且在ubuntu自动更新后的20上。
这是我的docker compose

# pull official base image
FROM python:3.9.13-slim as builder

# set work directory
WORKDIR /usr/src/app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install psycopg2 dependencies
RUN apt update \
    && apt install -y build-essential gcc python3-dev musl-dev libffi-dev libssl-dev postgresql-server-dev-all cargo git tk libmagic1 

# lint

RUN pip install filemagic
RUN pip install --upgrade pip
RUN pip install flake8
COPY . /usr/src/app/

# install dependencies
COPY ./requirements.txt .
RUN pip install wheel
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt

#########
# FINAL #
#########

# pull official base image
FROM python:3.9.13-slim

# create directory for the app user
RUN mkdir -p /home/app

# create the app user
# RUN addgroup -S app && adduser -S app -G app
RUN adduser --system --group app

# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/staticfiles
WORKDIR $APP_HOME

# install dependencies
RUN apt update && apt install -y tk
COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*

# copy entrypoint.sh
COPY ./entrypoint.sh $APP_HOME

# copy project
COPY . $APP_HOME

# chown all the files to the app user
RUN chown -R app:app $APP_HOME

RUN chmod +x $APP_HOME/entrypoint.sh

# change to the app user
USER app

# run entrypoint.prod.sh
ENTRYPOINT ["/home/app/web/entrypoint.sh"]

这就是错误

0 26.68 P

reparing to unpack .../libpython3.9-minimal_3.9.2-1_amd64.deb ...
#0 26.70 Unpacking libpython3.9-minimal:amd64 (3.9.2-1) ...
#0 27.21 Selecting previously unselected package python3.9-minimal.
#0 27.21 Preparing to unpack .../python3.9-minimal_3.9.2-1_amd64.deb ...
#0 27.23 Unpacking python3.9-minimal (3.9.2-1) ...
#0 27.79 Setting up libpython3.9-minimal:amd64 (3.9.2-1) ...
#0 27.82 Setting up python3.9-minimal (3.9.2-1) ...
#0 28.16 Traceback (most recent call last):
#0 28.17   File "/usr/lib/python3.9/py_compile.py", line 215, in <module>
#0 28.17     sys.exit(main())
#0 28.17   File "/usr/lib/python3.9/py_compile.py", line 207, in main
#0 28.17     compile(filename, doraise=True)
#0 28.17   File "/usr/lib/python3.9/py_compile.py", line 172, in compile
#0 28.17     importlib._bootstrap_external._write_atomic(cfile, bytecode, mode)
#0 28.17   File "<frozen importlib._bootstrap_external>", line 126, in _write_atomic
#0 28.18 PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.9/__pycache__/__future__.cpython-39.pyc.140199513461120'
#0 28.18 dpkg: error processing package python3.9-minimal (--configure):
#0 28.18  installed python3.9-minimal package post-installation script subprocess returned error exit status 1
#0 28.21 Errors were encountered while processing:
#0 28.21  python3.9-minimal
#0 28.37 E: Sub-process /usr/bin/dpkg returned an error code (1)
------
failed to solve: executor failed running [/bin/sh -c apt update     && apt install -y build-essential gcc python3-dev musl-dev libffi-dev libssl-dev postgresql-server-dev-all cargo git tk libmagic1]: exit code: 100
service "web" is not running container #1

我已经试过把python slim从3.9更新到3.10.x 3.1.x问题仍然存在

nkoocmlb

nkoocmlb1#

这个问题仅仅是因为我用snap安装了docker,删除了docker,用get-apt重新安装就解决了

相关问题