github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/cli/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  # context create
     8  
     9  ```markdown
    10  Usage:  docker context create [OPTIONS] CONTEXT
    11  
    12  Create a context
    13  
    14  Docker endpoint config:
    15  
    16  NAME                DESCRIPTION
    17  from                Copy Docker endpoint configuration from an existing context
    18  host                Docker endpoint on which to connect
    19  ca                  Trust certs signed only by this CA
    20  cert                Path to TLS certificate file
    21  key                 Path to TLS key file
    22  skip-tls-verify     Skip TLS certificate validation
    23  
    24  Kubernetes endpoint config:
    25  
    26  NAME                 DESCRIPTION
    27  from                 Copy Kubernetes endpoint configuration from an existing context
    28  config-file          Path to a Kubernetes config file
    29  context-override     Overrides the context set in the kubernetes config file
    30  namespace-override   Overrides the namespace set in the kubernetes config file
    31  
    32  Example:
    33  
    34  $ docker context create my-context \
    35        --description "some description" \
    36        --docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file"
    37  
    38  Options:
    39        --default-stack-orchestrator string   Default orchestrator for
    40                                              stack operations to use with
    41                                              this context
    42                                              (swarm|kubernetes|all)
    43        --description string                  Description of the context
    44        --docker stringToString               set the docker endpoint
    45                                              (default [])
    46        --kubernetes stringToString           set the kubernetes endpoint
    47                                              (default [])
    48        --from string                         Create the context from an existing context
    49  ```
    50  
    51  ## Description
    52  
    53  Creates a new `context`. This allows you to quickly switch the cli
    54  configuration to connect to different clusters or single nodes.
    55  
    56  ## Examples
    57  
    58  ### Create a context with a docker and kubernetes endpoint
    59  
    60  To create a context from scratch provide the docker and, if required,
    61  kubernetes options. The example below creates the context `my-context`
    62  with a docker endpoint of `/data/docker/run/docker.sock` and a kubernetes configuration
    63  sourced from the file `/home/me/my-kube-config`:
    64  
    65  ```bash
    66  $ docker context create \
    67      --docker host=unix:///data/docker/run/docker.sock \
    68      --kubernetes config-file=/home/me/my-kube-config \
    69      my-context
    70  ```
    71  
    72  ### Create a context based on an existing context
    73  
    74  Use the `--from=<context-name>` option to create a new context from
    75  an existing context. The example below creates a new context named `my-context`
    76  from the existing context `existing-context`:
    77  
    78  ```bash
    79  $ docker context create --from existing-context my-context
    80  ```
    81  
    82  If the `--from` option is not set, the `context` is created from the current context:
    83  
    84  ```bash
    85  $ docker context create my-context
    86  ```
    87  
    88  This can be used to create a context out of an existing `DOCKER_HOST` based script:
    89  
    90  ```bash
    91  $ source my-setup-script.sh
    92  $ docker context create my-context
    93  ```
    94  
    95  To source only the `docker` endpoint configuration from an existing context
    96  use the `--docker from=<context-name>` option. The example below creates a
    97  new context named `my-context` using the docker endpoint configuration from
    98  the existing context `existing-context` and a kubernetes configuration sourced
    99  from the file `/home/me/my-kube-config`:
   100  
   101  ```bash
   102  $ docker context create \
   103      --docker from=existing-context \
   104      --kubernetes config-file=/home/me/my-kube-config \
   105      my-context
   106  ```
   107  
   108  To source only the `kubernetes` configuration from an existing context use the
   109  `--kubernetes from=<context-name>` option. The example below creates a new
   110  context named `my-context` using the kuberentes configuration from the existing
   111  context `existing-context` and a docker endpoint of `/data/docker/run/docker.sock`:
   112  
   113  ```bash
   114  $ docker context create \
   115      --docker host=unix:///data/docker/run/docker.sock \
   116      --kubernetes from=existing-context \
   117      my-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`.
   122  
   123  Refer to the [`docker context update` reference](context_update.md) for details.