What is it you are trying to do? How did you build your ansible image?
It sounds like you are trying to run playbooks that are physically on your RedHat host from the ansible command that is inside your CentOS container which means you must share a volume between the host and the container so that the playbooks can be seen. Then when you invoke docker, you must map that volume to the location of the playbooks on your host.
Here is a sample
Dockerfile using Alpine (sorry I don’t do CentOS):
RUN apk update && apk add --no-cache \
RUN pip install ansible
CMD [ "ansible", "--version" ]
Notice that it includes
VOLUME /playbooks which exposes the
WORKDIR /playbooks volume inside the container. Then when you run it, you map it to the location of the playbooks on your host.
Dockerfile you can build an image called
ansible:alpine like this:
docker build -t ansible:alpine .
Then, for example, if the playbooks are in the current folder, and the main playbook was called
playbook.yaml, you would run it like this:
docker run --rm -it -v $(PWD):/playbooks ansible:alpine ansible-playbook -v playbook.yaml
That will run
ansible-playbook from with in the container using the playbooks that are on your host mapping your current folder
/playbooks inside the container.