github.com/panekj/cli@v0.0.0-20230304125325-467dd2f3797e/docs/reference/commandline/context_create.md (about) 1 # context create 2 3 <!---MARKER_GEN_START--> 4 Create a context 5 6 Docker endpoint config: 7 8 NAME DESCRIPTION 9 from Copy named context's Docker endpoint configuration 10 host Docker endpoint on which to connect 11 ca Trust certs signed only by this CA 12 cert Path to TLS certificate file 13 key Path to TLS key file 14 skip-tls-verify Skip TLS certificate validation 15 16 Example: 17 18 $ docker context create my-context --description "some description" --docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file" 19 20 21 ### Options 22 23 | Name | Type | Default | Description | 24 |:----------------------|:-----------------|:--------|:------------------------------------| 25 | `--description` | `string` | | Description of the context | 26 | [`--docker`](#docker) | `stringToString` | | set the docker endpoint | 27 | [`--from`](#from) | `string` | | create context from a named context | 28 29 30 <!---MARKER_GEN_END--> 31 32 ## Description 33 34 Creates a new `context`. This allows you to quickly switch the cli 35 configuration to connect to different clusters or single nodes. 36 37 ## Examples 38 39 ### <a name="docker"></a> Create a context with a docker endpoint (--docker) 40 41 To create a context from scratch provide the docker and, if required, 42 kubernetes options. The example below creates the context `my-context` 43 with a docker endpoint of `/var/run/docker.sock`: 44 45 ```console 46 $ docker context create \ 47 --docker host=unix:///var/run/docker.sock \ 48 my-context 49 ``` 50 51 ### <a name="from"></a> Create a context based on an existing context (--from) 52 53 Use the `--from=<context-name>` option to create a new context from 54 an existing context. The example below creates a new context named `my-context` 55 from the existing context `existing-context`: 56 57 ```console 58 $ docker context create --from existing-context my-context 59 ``` 60 61 If the `--from` option is not set, the `context` is created from the current context: 62 63 ```console 64 $ docker context create my-context 65 ``` 66 67 This can be used to create a context out of an existing `DOCKER_HOST` based script: 68 69 ```console 70 $ source my-setup-script.sh 71 $ docker context create my-context 72 ``` 73 74 To source the `docker` endpoint configuration from an existing context 75 use the `--docker from=<context-name>` option. The example below creates a 76 new context named `my-context` using the docker endpoint configuration from 77 the existing context `existing-context`: 78 79 ```console 80 $ docker context create \ 81 --docker from=existing-context \ 82 my-context 83 ``` 84 85 Docker endpoints configurations, as well as the description can be modified with 86 `docker context update`. 87 88 Refer to the [`docker context update` reference](context_update.md) for details.