Score:0

Build ansible Dockerfile results error Could not find pip3

uz flag
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?

Score:2
cn flag

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.

uz flag
I added additional ";" at the end of ```pip3 install "pywinrm>=0.2.2"``` line. It's working now - thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.