- 我尝试通过本地 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
,尝试对pip3
.