无法在docker容器中apt-get install(但pip install可以)

col17t5w  于 12个月前  发布在  Docker
关注(0)|答案(1)|浏览(228)

我有错误与apt-get但不是与pip安装。
这是我的dockerfile的一部分:

FROM python:3.11-bookworm

# Set the shell to Bash
SHELL ["/bin/bash", "-c"]
RUN apt-get update && \
    apt-get install libturbojpeg

# Set the working directory
WORKDIR /app

# Copy the contents of airflow-local-env into the container
# remember to build with the righ build context
# e.g 
COPY airflow-local-env .

# Install any needed packages specified in requirements.txt excluding apache-airflow
RUN pip install --upgrade pip
RUN grep -v 'apache-airflow' requirements.txt | xargs -n 1 pip install --no-cache-dir --no-build-isolation

# Set the PYTHONPATH to include the plugins directory
ENV PYTHONPATH=$PYTHONPATH:/app/plugins

字符串
在添加apt-get命令之前,一切正常。现在我得到了这些错误:

> [2/7] RUN apt-get update &&     apt-get install libturbojpeg:
0.227 Err:1 http://deb.debian.org/debian bookworm InRelease
0.227   407  authenticationrequired [IP: 10.12.9.140 8080]
0.289 Err:2 http://deb.debian.org/debian bookworm-updates InRelease
0.289   407  authenticationrequired [IP: 10.12.9.140 8080]
0.349 Err:3 http://deb.debian.org/debian-security bookworm-security InRelease
0.349   407  authenticationrequired [IP: 10.12.9.140 8080]
0.351 Reading package lists...
0.362 E: The repository 'http://deb.debian.org/debian bookworm InRelease' is not signed.
0.362 E: Failed to fetch http://deb.debian.org/debian/dists/bookworm/InRelease  407  authenticationrequired [IP: 10.12.9.140 8080]
0.362 E: Failed to fetch http://deb.debian.org/debian/dists/bookworm-updates/InRelease  407  authenticationrequired [IP: 10.12.9.140 8080]
0.362 E: The repository 'http://deb.debian.org/debian bookworm-updates InRelease' is not signed.
0.362 E: Failed to fetch http://deb.debian.org/debian-security/dists/bookworm-security/InRelease  407  authenticationrequired [IP: 10.12.9.140 8080]
0.362 E: The repository 'http://deb.debian.org/debian-security bookworm-security InRelease' is not signed.


在我看来,似乎有代理问题。但如果是这样的话,为什么pip install工作?
我已经用--network host标志构建了镜像。此外,在我的.docker/config.json中,代理已经配置好了(同样,pip工作正常)。此外,HTTP_PROXY/HTTPS_PROXY环境变量也配置好了。
我真的不知道问题出在哪里。知道吗?
编辑:我尝试了this answer中解释的方法(复制我本地的apt.conf)。它工作了,但我不喜欢这个解决方案。

r1wp621o

r1wp621o1#

我将本地/etc/apt/apt.conf复制到一个文件中,并将此文件复制到图像中:

COPY ./apt.conf /etc/apt/apt.conf

字符串
现在一切正常,但我的用户和pwd都在这个镜像中,我不喜欢这样。另外,因为我的其他同事能够构建镜像而无需做任何事情,所以我认为我的docker或代理配置存在问题。接受新想法

相关问题