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

col17t5w  于 2024-01-06  发布在  Docker
关注(0)|答案(1)|浏览(312)

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

  1. FROM python:3.11-bookworm
  2. # Set the shell to Bash
  3. SHELL ["/bin/bash", "-c"]
  4. RUN apt-get update && \
  5. apt-get install libturbojpeg
  6. # Set the working directory
  7. WORKDIR /app
  8. # Copy the contents of airflow-local-env into the container
  9. # remember to build with the righ build context
  10. # e.g
  11. COPY airflow-local-env .
  12. # Install any needed packages specified in requirements.txt excluding apache-airflow
  13. RUN pip install --upgrade pip
  14. RUN grep -v 'apache-airflow' requirements.txt | xargs -n 1 pip install --no-cache-dir --no-build-isolation
  15. # Set the PYTHONPATH to include the plugins directory
  16. ENV PYTHONPATH=$PYTHONPATH:/app/plugins

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

  1. > [2/7] RUN apt-get update && apt-get install libturbojpeg:
  2. 0.227 Err:1 http://deb.debian.org/debian bookworm InRelease
  3. 0.227 407 authenticationrequired [IP: 10.12.9.140 8080]
  4. 0.289 Err:2 http://deb.debian.org/debian bookworm-updates InRelease
  5. 0.289 407 authenticationrequired [IP: 10.12.9.140 8080]
  6. 0.349 Err:3 http://deb.debian.org/debian-security bookworm-security InRelease
  7. 0.349 407 authenticationrequired [IP: 10.12.9.140 8080]
  8. 0.351 Reading package lists...
  9. 0.362 E: The repository 'http://deb.debian.org/debian bookworm InRelease' is not signed.
  10. 0.362 E: Failed to fetch http://deb.debian.org/debian/dists/bookworm/InRelease 407 authenticationrequired [IP: 10.12.9.140 8080]
  11. 0.362 E: Failed to fetch http://deb.debian.org/debian/dists/bookworm-updates/InRelease 407 authenticationrequired [IP: 10.12.9.140 8080]
  12. 0.362 E: The repository 'http://deb.debian.org/debian bookworm-updates InRelease' is not signed.
  13. 0.362 E: Failed to fetch http://deb.debian.org/debian-security/dists/bookworm-security/InRelease 407 authenticationrequired [IP: 10.12.9.140 8080]
  14. 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复制到一个文件中,并将此文件复制到图像中:

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

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

相关问题