LinuxCommandLibrary

docker-context

Manage Docker connection configurations

TLDR

Create a context using a specific Docker endpoint

$ docker context create [my_context] --docker "host=[tcp://remote-host:2375]"
copy

Create a context based on the DOCKER_HOST environment variable
$ docker context create [my_context]
copy

Switch to a context
$ docker context use [my_context]
copy

List all contexts
$ docker context ls
copy

SYNOPSIS

docker context [COMMAND]

PARAMETERS

create [OPTIONS] CONTEXT
    Creates a new context.

export CONTEXT
    Exports a context to a tar or zip archive.

import CONTEXT
    Imports a context from a tar or zip archive.

inspect [CONTEXT]
    Displays detailed information on one or more contexts.

list
    Lists all available contexts.

rm CONTEXT [CONTEXT...]
    Removes one or more contexts.

show
    Shows the current context name.

update [OPTIONS] CONTEXT
    Updates a context.

use CONTEXT
    Sets the default context.

DESCRIPTION

The `docker context` command in Docker allows you to manage connection profiles, which are configurations that contain information about how to connect to a Docker daemon. This is useful for switching between different Docker environments easily, such as local development, staging, and production servers. You can create, inspect, update, and use different contexts to point your Docker client to the desired Docker host. Contexts store authentication details, TLS settings, and other necessary information for establishing a secure connection. Using contexts simplifies managing connections to multiple Docker environments, especially in complex development workflows and CI/CD pipelines. It enables you to avoid repeatedly specifying connection parameters, promoting efficiency and reducing the risk of errors. Switching between contexts is quick and easy, allowing for rapid changes in your working environment.

DOCKER CONTEXT TYPES

Docker supports multiple context types, primarily default (uses environment variables or default Docker socket) and kubernetes (connects to a Kubernetes cluster). When creating a context, the type can be specified, and options will vary accordingly. For example, a Kubernetes context requires connection details for the Kubernetes API server.

SEE ALSO

docker(1)

Copied to clipboard