-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker_compose does not allow to choose the project-directory when specifying more than one docker-compose file #48648
Comments
Hi @giovannipizzi, thank you for submitting this issue! |
Files identified in the description: If these files are inaccurate, please update the |
It would be great to get some feedback, so I can prepare a PR if you agree |
@giovannipizzi |
Files identified in the description: If these files are inaccurate, please update the |
!component =lib/ansible/modules/cloud/docker/docker_compose.py |
Files identified in the description: If these files are inaccurate, please update the |
Files identified in the description: If these files are inaccurate, please update the |
Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.
For further information, please see: |
SUMMARY
When specifying more than one file in the
docker_service
, theproject-directory
is assumed to be the one of the first docker-compose.yml file provided, and cannot be changed (even ifproject_src
is provided).ISSUE TYPE
COMPONENT NAME
docker_service
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Mac OS 10.13.6, but also happens on Ubuntu Linux 16.04 and 18.04
Using
docker-compose==1.23.1
from pipSTEPS TO REPRODUCE
Inside a folder, create two subfolders
a
andb
.Inside folder
a
, put the followingdocker-compose.yml
file:Inside folder
b
, put the followingdocker-compose.yml
file:and finally inside the
b
folder, create ab/dir
subfolder containing aDockerfile
with only the following line:The playbook to run (and to put in the
b
folder) is:EXPECTED RESULTS
The two docker-compose files are used, and the current folder is used as project-directory as well (i.e. the Dockerfile in the subdirectory
./dir
is found and used).ACTUAL RESULTS
This means that the
project-directory
is set from the path of the first file provided, and cannot be changed, even ifproject_src
is provided.Note that this is the behaviour of docker-compose. I.e. if I am in the
b
folder,the command
Fails with
and instead swapping the order works:
However, from the command line specifying explicitly a
--project-directory=.
makes it work correctly:The problem in ansible is that it is not possible to specify a
--project-directory
.Possible suggestions:
--project-directory
toself.options
in the code before callingcompose.cli.command.project_from_options
in the module taking the value fromproject_src
, if specified (however, I don't know if the two have a different meaning and it's not a good idea to merge them)project_directory
option to thedocker_service
module that would set this optionI would favour option 2.
In any case (or even if this is already possible somehow) I would suggest to add an entry to the examples in the documentation of the module, explaining how to properly deal with this use case.
If you let me know how you prefer to proceed, I can also prepare a PR.
The text was updated successfully, but these errors were encountered: