Docker
建構 ansible Dockerfile 結果錯誤找不到 pip3
- 我嘗試通過本地 Dockerfile 建構 ansible 的圖像:
- 我從以下 Docker 文件中獲得:快速入門:在 Docker 容器中配置 Ansible
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 /product
,CMD [ "/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 命令)
那麼,缺少什麼或者我需要修復什麼才能使其正常工作?
您的
Dockerfile
. 命令中的兩行沒有用orRUN
分隔。; \``&& \
ansible-galaxy collection install azure.azcollection; \ pip3 install "pywinrm>=0.2.2"
因此
ansible-galaxy
,嘗試對pip3
.