Create a context
Docker endpoint config:
NAME DESCRIPTION from Copy named context's 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
Example:
$ docker context create my-context --description "some description" --docker "host=tcp://myserver:2376,ca=/ca-file,cert=/cert-file,key=~/key-file"
| Name | Type | Default | Description |
|---|---|---|---|
--description |
string |
Description of the context | |
--docker |
stringToString |
set the docker endpoint | |
--from |
string |
create context from a named context |
Creates a new context. This allows you to quickly switch the cli
configuration to connect to different clusters or single nodes.
To create a context from scratch provide the docker and, if required,
kubernetes options. The example below creates the context my-context
with a docker endpoint of /var/run/docker.sock:
$ docker context create \
--docker host=unix:///var/run/docker.sock \
my-contextUse the --from=<context-name> option to create a new context from
an existing context. The example below creates a new context named my-context
from the existing context existing-context:
$ docker context create --from existing-context my-contextIf the --from option is not set, the context is created from the current context:
$ docker context create my-contextThis can be used to create a context out of an existing DOCKER_HOST based script:
$ source my-setup-script.sh
$ docker context create my-contextTo source the docker endpoint configuration from an existing context
use the --docker from=<context-name> option. The example below creates a
new context named my-context using the docker endpoint configuration from
the existing context existing-context:
$ docker context create \
--docker from=existing-context \
my-contextDocker endpoints configurations, as well as the description can be modified with
docker context update.
Refer to the docker context update reference for details.