# How to set the docker current working directory via commandline ansible-runner?

**URL:** <https://forum.ansible.com/t/how-to-set-the-docker-current-working-directory-via-commandline-ansible-runner/36092>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [December 9, 2021, 3:08pm UTC](https://forum.ansible.com/t/how-to-set-the-docker-current-working-directory-via-commandline-ansible-runner/36092 "2021-12-09T15:08:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [December 9, 2021, 3:08pm UTC](https://forum.ansible.com/t/how-to-set-the-docker-current-working-directory-via-commandline-ansible-runner/36092/1 "2021-12-09T15:08:06Z")

</div>

Hi everyone,

Apart from running locally the AWX jobs (see the other thread at [https://groups.google.com/g/awx-project/c/XhY-uDSxDIo](https://groups.google.com/g/awx-project/c/XhY-uDSxDIo) for the motivation), I am also focusing on running ansible-runner locally in commandline mode on our existing repository (with process isolation done via docker).

This playbook repository has a particular structure which does not abide by the ansible-runner input directory hierarchy ([https://ansible-runner.readthedocs.io/en/stable/intro/#inputdir](https://ansible-runner.readthedocs.io/en/stable/intro/#inputdir)). I am thus using the several ansible-runner commandline parameters to point at the various pieces that are required.

I am stumbling upon an issue in that the playbook I specify cannot be found by the newly spawned container:  
ERROR! the playbook: deploy-stack.yaml could not be found

Investigating in debug mode, I see this is because the underlying docker commandline always has —workdir /runner/project specified whereas the playbook is actually located/mounted under /runner/deploy-stack.yaml

If I edit the docker commandline and run it manually to specify --workdir /runner, then ansible-playbook starts and find the playbook, as expected.

I have looked into the ansible-runner source (I am using v2.1.1) and it seems the logic which sets the working directory is at [https://github.com/ansible/ansible-runner/blob/2.1.1/ansible\_runner/config/\_base.py#L451](https://github.com/ansible/ansible-runner/blob/2.1.1/ansible_runner/config/_base.py#L451)

It should be overridable via either self.container\_dir or self.host\_cwd. The thing is, I can’t find where the commandline entry point (and not the Python one) is actually setting those values.

Could someone explain how the container working directory can be set when being called in commandline mode?

Many thanks for your help!

Vincent

PS: full log attached (sorry for the non-printable characters, this was captured via tee)

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [December 9, 2021, 3:08pm UTC](https://forum.ansible.com/t/how-to-set-the-docker-current-working-directory-via-commandline-ansible-runner/36092/2 "2021-12-09T15:08:53Z")

</div>

With the file this time.

> **(attachments)**
>
> [ansible-runner-log.txt](https://forum.ansible.com/uploads/short-url/2gVigGX7qWLCvL4f5U3ClW7VbtM.txt) (17.8 KB)

---

<div class="post-metadata">

**Author:** ![Vincent\_Rubiolo](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vincent\_Rubiolo](https://forum.ansible.com/u/Vincent_Rubiolo)\
**Post date:** [December 20, 2021, 7:57pm UTC](https://forum.ansible.com/t/how-to-set-the-docker-current-working-directory-via-commandline-ansible-runner/36092/3 "2021-12-20T19:57:23Z")

</div>

Hi everyone,

After discussing things w/ Alan on a separate ansible-runner ticket, I have opened [https://github.com/ansible/ansible-runner/issues/945](https://github.com/ansible/ansible-runner/issues/945) to track my issue.

Vincent
