docker context create
Create a context
Usage
$ docker context create [OPTIONS] CONTEXT
Refer to the options section for an overview of available OPTIONS
for this command.
Description
Creates a new context
. This allows you to quickly switch the cli
configuration to connect to different clusters or single nodes.
For example uses of this command, refer to the examples section below.
Options
Name, shorthand | Default | Description |
--description |
Description of the context | |
--docker |
set the docker endpoint | |
--from |
create context from a named context |
Examples
Create a context with a docker endpoint (--docker)
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-context
Create a context based on an existing context (--from)
Use 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-context
If the --from
option is not set, the context
is created from the current context:
$ docker context create my-context
This can be used to create a context out of an existing DOCKER_HOST
based script:
$ source my-setup-script.sh
$ docker context create my-context
To 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-context
Docker endpoints configurations, as well as the description can be modified with
docker context update
.
Refer to the docker context update
reference for details.
Parent command
Command | Description |
---|---|
docker context | Manage contexts |
Related commands
Command | Description |
docker context create | Create a context |
docker context export | Export a context to a tar archive FILE or a tar stream on STDOUT. |
docker context import | Import a context from a tar or zip file |
docker context inspect | Display detailed information on one or more contexts |
docker context ls | List contexts |
docker context rm | Remove one or more contexts |
docker context show | Print the name of the current context |
docker context update | Update a context |
docker context use | Set the current docker context |