Ansible-runner inside Docker

iamroddo
Wed, 12 Feb 2025 08:46:11 +0000
Get Help

I am exploring the use of ansible-runner. I have been able to get it to run on the CLI on my Mac in my host with env/settings as below …

container_image: ee-29-rhel8
process_isolation_executable: docker
process_isolation: true
container_volume_mounts:
- /Users/rod/Documents/Development/ansible-repo:/workspaces/ansible-repo
container_options:
- '--platform=linux/amd64'
debug: true

… and executing ansible-runner run /Users/rod/Documents/Development/ansible-repo/ansible-runner -p /workspaces/ansible-repo/experiment.yml

However when I try running ansible-runner in a Docker container spun up VS Code Devcontainer I get the following error …

root@309828da25ff:/workspaces/ansible-repo# ansible-runner run ansible-runner/ -p experiment.yml
docker: Error response from daemon: Mounts denied:
The path /workspaces/ansible-repo/ansible-runner is not shared from the host and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.
See https://docs.docker.com/desktop/settings/mac/#file-sharing for more info.
root@309828da25ff:/workspaces/ansible-repo#

The command docker run -it --platform=linux/amd64 --rm -v /Users/rod/Documents/Development/ansible-repo:/workspaces/ansible-repo ee-29-rhel8 bash executes just fine from within the Devcontainer Docker container.

However the path mentioned in this error cannot be configured in Docker Desktop as the path /workspaces/ansible-repo/ansible-runner is only known in the container and not on the host.

When I execute ansible-runner run ansible-runner -p ansible-runner/experiment.yml --debug, the output contains command: docker run --rm --tty --interactive --workdir /runner/project -v /workspaces/ansible-repo/ansible-runner/:/runner/:Z --env-file /workspaces/ansible-repo/ansible-runner/artifacts/14b474b7-2692-46ea-879d-82d132e70d54/env.list --user=0 --name ansible_runner_14b474b7-2692-46ea-879d-82d132e70d54 --platform=linux/amd64 ee-29-rhel8 ansible-playbook -i /runner/inventory -e @/runner/env/extravars experiment.yml.

I think this command would succeed if instead of trying to mount /workspaces/ansible-repo/ansible-runner/ to /runner/, it would mount /Users/rod/Documents/Development/ansible-repo:/workspaces/ansible-repo/ansible-runner to /runner/.

Any ideas?

2 posts - 2 participants