Skip to content

Docker Context for remote host management #647

Open
@shantanoo-desai

Description

@shantanoo-desai
SUMMARY

Since Docker v18.09+ it is possible to use the same docker CLI on a Controller Node to get access to remote Managed Nodes. This is generally achieved initially by using docker context create ....

This command is capable enough to work with Docker Swarm, Kubernetes for Orchestration as well for standalone remote nodes over TCP (with / without TLS), as well as SSH.

Thorough Documentation can be found on Docker Docs: Docker Context.

The tool also provides facilities or exporting / importing these created contexts as well as controlling the Docker Containers on Remote nodes.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

community.docker.docker_context

ADDITIONAL INFORMATION

This may be an example module called docker_context:

- name: Create Docker Context for Hosts in Inventory
  community.docker.docker_context:
    name: "ctx-{{ inventory_hostname }}"
    description: "docker context for remote node: {{ inventory_hostname }}"
    state: created
    endpoint: "ssh://{{ inventory_hostname }}"

There are certainly benefits where at least from the CLI, the following examples can perform tasks, which are performed locally, also on a remote machine

# list running docker containers on `my-host-1`

docker --context=ctx-my-host-1 ps -a

In conjuction with docker compose one can deploy a compose application without needing to copy a compose file to the remote machine

# executing in the same directory as `docker-compose.yml`
docker --context=ctx-my-host-1 compose up -d

A well written Docker Post for deploying on Remote Docker Host with docker compose

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions