I am trying to build an image using a dockerfile that has ansible installed. However when I start the container and try to get Ansible verion I get bash: ansible: command not found.
This is my dockerfile
FROM centos:centos7.7.1908
RUN yum check-update; \
yum install -y gcc libffi-devel python3 epel-release; \
yum install -y openssh-clients; \
yum install -y sshpass; \
yum clean all; \
pip3 install --upgrade pip
RUN pip3 install "ansible==2.9.12"; \
pip3 install boto; \
pip3 install boto3; \
pip3 install "pywinrm>=0.3.0"
I used docker build -t ansible:latest . It does have pywinrm, boto and boto3
[root@7dbc2587a975 /]# pip3 list
Package Version
------------------ ---------
boto 2.49.0
boto3 1.23.10
botocore 1.26.10
certifi 2022.9.24
cffi 1.15.1
charset-normalizer 2.0.12
cryptography 38.0.4
idna 3.4
jmespath 0.10.0
ntlm-auth 1.5.0
pip 21.3.1
pycparser 2.21
python-dateutil 2.8.2
pywinrm 0.4.3
requests 2.27.1
requests-ntlm 1.1.0
s3transfer 0.5.2
setuptools 39.2.0
six 1.16.0
urllib3 1.26.13
xmltodict 0.13.0
I tried to remove all images docker rmi ansible
Edit: final docker file which seems to work:
FROM centos:centos7.7.1908
ENV LANG=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8
RUN yum check-update; \
yum install -y gcc libffi-devel python3 epel-release; \
yum install -y openssh-clients; \
yum install -y sshpass; \
yum clean all; \
pip3 install --upgrade pip
RUN pip3 install "ansible==2.9.12" && \
pip3 install boto && pip3 install boto3 && pip3 install "pywinrm>=0.3.0"