构建ansible Dockerfile结果错误Could not find pip3

构建ansible Dockerfile结果错误Could not find pip3
FROM centos:7

RUN yum check-update; \
    yum install -y gcc libffi-devel python3 epel-release; \
    yum install -y python3-pip; \
    yum install -y wget; \
    yum clean all

RUN pip3 install --upgrade pip; \
    pip3 install "ansible"; \
    wget -q https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt; \
    pip3 install -r requirements-azure.txt; \
    rm requirements-azure.txt; \
    ansible-galaxy collection install azure.azcollection
    pip3 install "pywinrm>=0.2.2" 

WORKDIR /product

CMD [ "/usr/sbin/init" ]
  • 最后三行是我加的:pip3 install "pywinrm>=0.2.2",,WORKDIR /productCMD [ "/usr/sbin/init" ]
  • 我通过 VSCODE 运行此 Dockerfile > 右键单击​​ docker-compose 文件并选择Compose Up选项
version: '2'
services:
  ansible:
    container_name: ansible
    hostname: ansible
    image: ansible
    build:
      context: .
      dockerfile: Dockerfile
    volumes: 
      - ../../../../../../../:/product
    dns:
      - 200.0.10.100
  • 我已经成功构建并运行了这个镜像,但最近我创建了新的 git 存储库并将其克隆到我的主机。我将这两个文件放在一个文件夹中。
  • 构建图像的结果是,我收到以下错误:
#6 187.2 ERROR! Neither the collection requirement entry key 'name', nor 'source' point to a concrete resolvable collection artifact. Also 'name' is not an FQCN. A valid collection name must be in the format <namespace>.<collection>. Please make sure that the namespace and the collection name  contain characters from [a-zA-Z0-9_] only.     
#6 187.2
#6 187.2 Could not find pip3.
------
executor failed running [/bin/sh -c yum install -y python3-pip;     pip3 install --upgrade pip;     pip3 install "ansible";     wget -q https://raw.githubusercontent.com/ansible-collections/azure/dev/requirements-azure.txt;     pip3 install -r requirements-azure.txt;     rm requirements-azure.txt;     ansible-galaxy collection install azure.azcollection     pip3 install "pywinrm>=0.2.2"]: exit code: 1
ERROR: Service 'ansible' failed to build : Build failed
The terminal process "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command docker-compose -f "images\local\ansible\v210\docker-compose.yml" up -d --build" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.
  • 看起来第一个RUN命令根本没有执行
  • 我尝试了docker build .命令docker-compose up- 创建容器失败
  • 我尝试清理所有容器、图像和卷并重新构建 - 但创建容器失败(我遵循以下指南:在此处输入链接描述,并且还使用了 rm 命令)

那么,缺少了什么或者我需要修复什么才能使其正常工作?

答案1

您的 中有错误Dockerfile。命令中的两行RUN没有用; \或分隔&& \

ansible-galaxy collection install azure.azcollection; \
pip3 install "pywinrm>=0.2.2"

ansible-galaxy因此,尝试执行某项操作的命令会返回错误pip3

相关内容