@@ -53,23 +53,30 @@ Options:
5353Creates a new ` context ` . This allows you to quickly switch the cli
5454configuration to connect to different clusters or single nodes.
5555
56+ ## Examples
57+
58+ ### Create a context with a docker and kubernetes endpoint
59+
5660To create a context from scratch provide the docker and, if required,
5761kubernetes options. The example below creates the context ` my-context `
5862with a docker endpoint of ` /var/run/docker.sock ` and a kubernetes configuration
5963sourced from the file ` /home/me/my-kube-config ` :
6064
6165``` bash
62- $ docker context create my-context \
63- --docker host=/var/run/docker.sock \
64- --kubernetes config-file=/home/me/my-kube-config
66+ $ docker context create \
67+ --docker host=unix:///var/run/docker.sock \
68+ --kubernetes config-file=/home/me/my-kube-config \
69+ my-context
6570```
6671
72+ ### Create a context based on an existing context
73+
6774Use the ` --from=<context-name> ` option to create a new context from
6875an existing context. The example below creates a new context named ` my-context `
6976from the existing context ` existing-context ` :
7077
7178``` bash
72- $ docker context create my-context -- from existing-context
79+ $ docker context create -- from existing-context my-context
7380```
7481
7582If the ` --from ` option is not set, the ` context ` is created from the current context:
@@ -92,9 +99,10 @@ the existing context `existing-context` and a kubernetes configuration sourced
9299from the file ` /home/me/my-kube-config ` :
93100
94101``` bash
95- $ docker context create my-context \
96- --docker from=existing-context \
97- --kubernetes config-file=/home/me/my-kube-config
102+ $ docker context create \
103+ --docker from=existing-context \
104+ --kubernetes config-file=/home/me/my-kube-config \
105+ my-context
98106```
99107
100108To source only the ` kubernetes ` configuration from an existing context use the
@@ -103,10 +111,13 @@ context named `my-context` using the kuberentes configuration from the existing
103111context ` existing-context ` and a docker endpoint of ` /var/run/docker.sock ` :
104112
105113``` bash
106- $ docker context create my-context \
107- --docker host=/var/run/docker.sock \
108- --kubernetes from=existing-context
114+ $ docker context create \
115+ --docker host=unix:///var/run/docker.sock \
116+ --kubernetes from=existing-context \
117+ my-context
109118```
110119
111120Docker and Kubernetes endpoints configurations, as well as default stack
112- orchestrator and description can be modified with ` docker context update `
121+ orchestrator and description can be modified with ` docker context update ` .
122+
123+ Refer to the [ ` docker context update ` reference] ( context_update.md ) for details.
0 commit comments