github.com/itscaro/cli@v0.0.0-20190705081621-c9db0fe93829/docs/reference/commandline/context_create.md (about) 1 --- 2 title: "context create" 3 description: "The context create command description and usage" 4 keywords: "context, create" 5 --- 6 7 <!-- This file is maintained within the docker/cli GitHub 8 repository at https://github.com/docker/cli/. Make all 9 pull requests against that repo. If you see this file in 10 another repository, consider it read-only there, as it will 11 periodically be overwritten by the definitive file. Pull 12 requests which include edits to this file in other repositories 13 will be rejected. 14 --> 15 16 # context create 17 18 ```markdown 19 Usage: docker context create [OPTIONS] CONTEXT 20 21 Create a context 22 23 Docker endpoint config: 24 25 NAME DESCRIPTION 26 from Copy Docker endpoint configuration from an existing context 27 host Docker endpoint on which to connect 28 ca Trust certs signed only by this CA 29 cert Path to TLS certificate file 30 key Path to TLS key file 31 skip-tls-verify Skip TLS certificate validation 32 33 Kubernetes endpoint config: 34 35 NAME DESCRIPTION 36 from Copy Kubernetes endpoint configuration from an existing context 37 config-file Path to a Kubernetes config file 38 context-override Overrides the context set in the kubernetes config file 39 namespace-override Overrides the namespace set in the kubernetes config file 40 41 Example: 42 43 $ docker context create my-context \ 44 --description "some description" \ 45 --docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file" 46 47 Options: 48 --default-stack-orchestrator string Default orchestrator for 49 stack operations to use with 50 this context 51 (swarm|kubernetes|all) 52 --description string Description of the context 53 --docker stringToString set the docker endpoint 54 (default []) 55 --kubernetes stringToString set the kubernetes endpoint 56 (default []) 57 --from string Create the context from an existing context 58 ``` 59 60 ## Description 61 62 Creates a new `context`. This allows you to quickly switch the cli 63 configuration to connect to different clusters or single nodes. 64 65 To create a context from scratch provide the docker and, if required, 66 kubernetes options. The example below creates the context `my-context` 67 with a docker endpoint of `/var/run/docker.sock` and a kubernetes configuration 68 sourced from the file `/home/me/my-kube-config`: 69 70 ```bash 71 $ docker context create my-context \ 72 --docker host=/var/run/docker.sock \ 73 --kubernetes config-file=/home/me/my-kube-config 74 ``` 75 76 Use the `--from=<context-name>` option to create a new context from 77 an existing context. The example below creates a new context named `my-context` 78 from the existing context `existing-context`: 79 80 ```bash 81 $ docker context create my-context --from existing-context 82 ``` 83 84 If the `--from` option is not set, the `context` is created from the current context: 85 86 ```bash 87 $ docker context create my-context 88 ``` 89 90 This can be used to create a context out of an existing `DOCKER_HOST` based script: 91 92 ```bash 93 $ source my-setup-script.sh 94 $ docker context create my-context 95 ``` 96 97 To source only the `docker` endpoint configuration from an existing context 98 use the `--docker from=<context-name>` option. The example below creates a 99 new context named `my-context` using the docker endpoint configuration from 100 the existing context `existing-context` and a kubernetes configuration sourced 101 from the file `/home/me/my-kube-config`: 102 103 ```bash 104 $ docker context create my-context \ 105 --docker from=existing-context \ 106 --kubernetes config-file=/home/me/my-kube-config 107 ``` 108 109 To source only the `kubernetes` configuration from an existing context use the 110 `--kubernetes from=<context-name>` option. The example below creates a new 111 context named `my-context` using the kuberentes configuration from the existing 112 context `existing-context` and a docker endpoint of `/var/run/docker.sock`: 113 114 ```bash 115 $ docker context create my-context \ 116 --docker host=/var/run/docker.sock \ 117 --kubernetes from=existing-context 118 ``` 119 120 Docker and Kubernetes endpoints configurations, as well as default stack 121 orchestrator and description can be modified with `docker context update`