0
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" ]
  • The last three lines are my addition: pip3 install "pywinrm>=0.2.2", WORKDIR /product, CMD [ "/usr/sbin/init" ]
  • I run this Dockerfile by VSCODE > right click on docker-compose file and selecting Compose Up option
version: '2'
services:
  ansible:
    container_name: ansible
    hostname: ansible
    image: ansible
    build:
      context: .
      dockerfile: Dockerfile
    volumes: 
      - ../../../../../../../:/product
    dns:
      - 200.0.10.100
  • I already succeeded to build and run this image, but recently I created new git repositories and clone them to my host. There I place those two file in one folder.
  • As a results of building the image, I got the following errors:
#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.
  • It is look like the first RUN command isn't executing at all
  • I tried docker build . and docker-compose up commands - failed to create container
  • I tried to clean all my container, images and volumes and build again - failed to create container (I followed this guide: enter link description here, and also used rm command)

So, what is missing OR what should I need to fix in order it to be worked?

Hiddai
  • 67
  • 2
  • 10

1 Answers1

2

You have an error in your Dockerfile. Two lines in the RUN command are not separated by a ; \ or && \.

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

So the error is returned by the ansible-galaxy command that tries to do something with pip3.

Romain
  • 207
  • 1
  • 6
  • I added additional ";" at the end of ```pip3 install "pywinrm>=0.2.2"``` line. It's working now - thanks! – Hiddai Jul 14 '21 at 12:34