docker / docker/cli

Multi-hosts contexts

Open
#3,352 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/context kind/feature
Dominant language
Go
Stars
6.1k
Forks
2.2k
Avg merge
1d 15h
Merged PRs (30d)
43

Description

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 🙂

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the docker context create and docker context inspect behavior described in the issue, then trace how stack deploy selects its Docker endpoint. Define how multiple --docker hosts are stored and tried, and verify that commands can move to an available host when the first node is down.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.