【发布时间】:2022-01-09 00:38:27
【问题描述】:
我正在尝试使用 Dockerfile 安装 python 和 pip & Ansible,但出现此错误
/bin/sh: 1: python: not found
The command '/bin/sh -c curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py && python get-pip.py && python -m pip install --upgrade "pip < 21.0" && pip install ansible --upgrade' returned a non-zero code: 127
ERROR: Service 'jenkins' failed to build : Build failed
这是我的 Dockerfile:
FROM jenkins/jenkins
USER root
RUN curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
python get-pip.py && \
python -m pip install --upgrade "pip < 21.0" && \
pip install ansible --upgrade
USER jenkins
注意:我在另一个 Dockerfile 上使用了相同的指令,并且没有错误。这是来自 CentOS 镜像的 Dockerfile:
FROM centos:7
RUN yum update -y && \
yum -y install openssh-server && \
yum install -y passwd
RUN useradd remote_user && \
echo "password" | passwd remote_user --stdin && \
mkdir /home/remote_user/.ssh && \
chmod 700 /home/remote_user/.ssh
COPY remote-key.pub /home/remote_user/.ssh/authorized_keys
RUN chown remote_user:remote_user -R /home/remote_user && \
chmod 600 /home/remote_user/.ssh/authorized_keys
RUN /usr/sbin/sshd-keygen
RUN yum -y install mysql
RUN curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
python get-pip.py && \
python -m pip install --upgrade "pip < 21.0" && \
pip install awscli --upgrade
CMD /usr/sbin/sshd -D
【问题讨论】:
-
请不要使用“已解决!”进行编辑。您提供了一个自我回答,这是继续进行的好方法。您将能够在几个小时内接受该自我回答。
-
python 没有安装在你的基础镜像中......你为什么不在启动所有这些 python 命令之前简单地安装它?
标签: python docker jenkins ansible dockerfile