Skip to content

Multi-hosts contexts #3352

@akerouanton

Description

@akerouanton

Currently docker context create points to only a single host. It's great but not perfect when dealing with Swarm clusters. Although Swarm clusters could be seen conceptually as one big computer where services are deployed, there's still a loophole: when it comes to automatically deploy a stack (eg. using a shell script/Makefile), stack deploy has to be run on a predefined manager node. If that node is actually down for some reason, that script will fail. That's particularly problematic when the given script is run by a CI.

Docker contexts could alleviate this problem by allowing users to define multiple hosts for a single context. When running a command using this sort of contexts, the CLI would check if that host is available and would switch to another host until it finds an available node before running the command.

docker context create supports providing multiple --docker flags but only the last one is saved in the context:

$ docker context create prod \
    --docker "host=ssh://prod.node1" \
    --docker "host=ssh://prod.node2" \
    --docker "host=ssh://prod.node3"

$ docker context inspect prod
[
    {
        ...
        "Endpoints": {
            "docker": {
                "Host": "ssh://prod.node3",
                "SkipTLSVerify": false
            }
        },
        ...
    }
]

I'm willing to implement it if you're ok with this feature 🙂

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