mirror of https://github.com/docker/cli.git
2.8 KiB
2.8 KiB
title | description | keywords |
---|---|---|
context create | The context create command description and usage | context, create |
context create
Usage: docker context create [OPTIONS] CONTEXT
Create a context
Docker endpoint config:
NAME DESCRIPTION
from-current Copy current Docker endpoint configuration
host Docker endpoint on which to connect
ca Trust certs signed only by this CA
cert Path to TLS certificate file
key Path to TLS key file
skip-tls-verify Skip TLS certificate validation
Kubernetes endpoint config:
NAME DESCRIPTION
from-current Copy current Kubernetes endpoint configuration
config-file Path to a Kubernetes config file
context-override Overrides the context set in the kubernetes config file
namespace-override Overrides the namespace set in the kubernetes config file
Example:
$ docker context create my-context --description "some description" --docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file"
Options:
--default-stack-orchestrator string Default orchestrator for
stack operations to use with
this context
(swarm|kubernetes|all)
--description string Description of the context
--docker stringToString set the docker endpoint
(default [])
--kubernetes stringToString set the kubernetes endpoint
(default [])
Description
Creates a new context
. This will allow you to quickly switch the cli configuration to connect to different clusters or single nodes.
To create a context
out of an existing DOCKER_HOST
based script, you can use the from-current
config key:
$ source my-setup-script.sh
$ docker context create my-context --docker "from-current=true"
Similarly, to reference the currently active Kubernetes configuration, you can use --kubernetes "from-current=true"
:
$ export KUBECONFIG=/path/to/my/kubeconfig
$ docker context create my-context --kubernetes "from-current=true" --docker "host=/var/run/docker.sock"
Docker and Kubernetes endpoints configurations, as well as default stack orchestrator and description can be modified with docker context update