Skip to content

cli/command/container: remove dependency on cli/compose/loader.ParseVolume #6188

Closed

Description

@thaJeztah

Description

Commit 732261f rewrote parsing of the --mount flag to use the compose "loader" code;

As an effect, users of the cli that import the container package also get all of "compose" (stack) as a dependency. We should split the volume / mount parsing logic to a separate package if possible.

I noticed this while looking what parts of docker/cli were used by compose.

Activity

  1. mayooot commented on Jul 22, 2025

    @mayooot

    @thaJeztah Hi, I can do it.

  2. thaJeztah commented on Jul 22, 2025

    @thaJeztah
    MemberAuthor

    Thanks! For transparency; I have not dug in deep yet to see what's involved, so there may be some fun challenges.

    The main reason I opened this ticket is that we're trying to provide a cleaner "Go" API for our projects, and have a better separation between packages that are designed (or "expected") to be used by others, and those that are for local / internal use.

    While looking at compose (which currently has to use some parts of the CLI codebase), I noticed that it imports the compose pacakge from docker/cli, which brings a lot of code with it that docker compose doesn't need. Some of those also involve text/template which is known to be bad or memory use, so trying to avoid that to be imported in places it's not needed where possible.

    tree -d ./vendor/github.com/docker/cli/cli/
    ./vendor/github.com/docker/cli/cli/
    ├── command
    ...
    ├── compose
    │   ├── interpolation
    │   ├── loader
    │   ├── schema
    │   │   └── data
    │   ├── template
    │   └── types
    ...

    The tricky bit here may be that the current implementation of loader.ParseVolume may still need a rewrite on its own, so IDEALLY we'd keep it internal somehow (so that it doesn't become a public API that we can't change).

    Input and suggestions are more than welcome; also happy to have a closer look, but feel free to make a start (but be prepared for going through a couple of iterations 😅).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions