You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 Inventorycommunity.docker.docker_context:
name: "ctx-{{ inventory_hostname }}"description: "docker context for remote node: {{ inventory_hostname }}"state: createdendpoint: "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
importdockerclient=docker.DockerClient(base_url="ssh://<user>@<hostname>", use_ssh_client=True)
client.containers.list() # will show containers on the remote machine
This however requires paramiko to be installed as a pip package to make the use_ssh_client parameter work. I haven't got around with how to use the Context and ContextAPI
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 usingdocker 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
COMPONENT NAME
community.docker.docker_context
ADDITIONAL INFORMATION
This may be an example module called
docker_context
: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
The text was updated successfully, but these errors were encountered: