我的Dockerfile中有以下内容:
...
USER $user
# Set default python version to 3
RUN alias python=python3
RUN alias pip=pip3
WORKDIR /app
# Install local dependencies
RUN pip install --requirement requirements.txt --user
在构建图像时,我得到以下信息:
Step 13/22 : RUN alias pip=pip3
---> Running in dc48c9c84c88
Removing intermediate container dc48c9c84c88
---> 6c7757ea2724
Step 14/22 : RUN pip install --requirement requirements.txt --user
---> Running in b829d6875998
/bin/sh: pip: command not found
如果我在pip
上面设置了一个别名,为什么它不能被识别
Ps:我不想使用.bashrc
加载别名
问题是,别名只存在于图像中的中间层。请尝试以下操作:
在这里测试:
这是因为每个层都会启动一个新的bash会话,因此别名将在以下层中丢失
要保持一个稳定的别名,可以像python在其official image中那样使用符号链接:
注意使用
python3-pip
包捆绑pip。调用pip
时,最好使用python -m pip
语法,因为它可以确保所调用的pip是与python安装相关的:相关问题 更多 >
编程相关推荐