如何在Docker镜像中使用自定义pip.conf?

huangapple go评论63阅读模式
英文:

How do I use a custom pip.conf in a docker image?

问题

你可以如下配置Docker容器使用自定义的pip.conf文件:

FROM python:3.9

COPY pip.conf ~/.config/pip/pip.conf

其中 pip.conf 是指向专有软件包仓库的pip配置文件的副本。

英文:

How can I configure a Docker container to use a custom pip.conf file?

This does not (seem to) work for me:

from python:3.9

COPY pip.conf ~/.config/pip/pip.conf

where pip.conf is a copy of the pip configuration that points to a proprietary package repository.

答案1

得分: 2

问题在于~的扩展。只需这样定义,明确使用目标路径。

from python:3.9

COPY pip.conf /root/.config/pip/pip.conf

如果您想要使用除/root/.config之外的内容,请考虑添加WORKDIR指令,并指定相对于该路径的路径。

英文:

The problem is the ~ expansion. Just define like this, using the dest path explicitly.

from python:3.9

COPY pip.conf /root/.config/pip/pip.conf

If you want to use something other than /root/.config then consider to add a WORKDIR instruction and specify paths relative to that.

huangapple
  • 本文由 发表于 2023年2月7日 05:04:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75366567.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定