Skip to content
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

Using Docker Compose as a library #387

Open
glours opened this issue Jul 8, 2022 · 4 comments
Open

Using Docker Compose as a library #387

glours opened this issue Jul 8, 2022 · 4 comments
Assignees
Labels
compose Improvements to Docker Compose

Comments

@glours
Copy link

glours commented Jul 8, 2022

Tell us about your request
Provide a stable Golang API for Docker Compose to let developers use Compose inside their own development without doing shell out.

Which service(s) is this request for?
Docker Compose

Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard?
We have users asking if they can the cmd or pkg packages as a stable reference to embed Compose inside their own development. For now the answer is that we don't guarantee backward compatibility in Compose internals between 2 versions.
We may consider to make interfaces present in pkg directory more stable and support an API usage of those interfaces.

Are you currently working around the issue?
Not especially but the interfaces of Compose V2 are pretty stable now.

Additional context
docker/compose#9602
docker/compose#9579

@glours glours added the community_new New idea raised by a community contributor label Jul 8, 2022
@stephanierifai stephanierifai added compose Improvements to Docker Compose and removed community_new New idea raised by a community contributor labels Jul 12, 2022
@dockertopia
Copy link

cc (me): @dockertopia so I can see this also in my PR queries.

@shantanoo-desai
Copy link

shantanoo-desai commented Sep 8, 2022

Description

An interesting requirement would be for Ansible.

Currently the community.docker is widely used Ansible Collection. It currently depends on Compose v1.x because Ansible Modules / Plugins generally depend on Python Libraries / APIs. Since v1.x is deprecated, and the compose v2 is a standalone Golang plugin, it becomes difficult to implement / update the collection.

Possible Solution

There is a possible solution python-on-whales which is generally just a Wrapper over the Docker CLI, as opposed to docker pip package which talks directly Docker Engine.

However, based on the discussion for the community.docker future roadmap it is still under consideration by the Maintainer. A possible exposed library / API would be a great help especially the current DevOps / IaaC landscape.

cc @felixfontein (maintainer of Ansible community.docker collection), might have some feedback here for community.docker for docker compose v2 roadmap

@RosieGarcia RosieGarcia assigned RosieGarcia and hyu and unassigned RosieGarcia Oct 27, 2022
@craph
Copy link

craph commented Dec 1, 2022

Any updates on this subjects ?

@felixfontein
Copy link

Using Docker Compose as a library isn't useful for Ansible since Docker Compose isn't written in Python anymore, but in Go. But having a way to get machine readable output (see also docker/compose#10872) for commands such as docker compose up, docker compose down, docker compose pull, docker compose stop, etc. would really help a lot. I've been looking at implementing support for Docker Compose v2 in Ansible modules during the last week and it has been a really frustrating experience, I constantly find new ways messages are written to stderr.

At least having a way to enable JSON stream output with some basic structure (that can easily be extended since it's JSON) would be extremely helpful to be able to use Docker Compose by shelling out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compose Improvements to Docker Compose
Projects
None yet
Development

No branches or pull requests

8 participants