← 返回命令列表

Linux command

docker-context 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

List contexts

docker context ls

Show current context

docker context show

Create a new context

docker context create [name] --docker "host=ssh://[user@host]"

Switch to context

docker context use [name]

Remove a context

docker context rm [name]

Inspect context details

docker context inspect [name]

说明

docker context manages Docker contexts, which are configuration profiles that store connection information for different Docker engines. Contexts enable seamless switching between local, remote, and cloud-based Docker hosts without manually reconfiguring connection settings. Each context contains endpoint information, TLS certificates, and other metadata needed to communicate with a Docker daemon. This is particularly useful for developers and operators who work with multiple Docker environments, such as local development, staging servers, and production clusters. The default context named "default" connects to the local Docker daemon via Unix socket. Additional contexts can be created to connect to remote Docker hosts over SSH, TCP, or other protocols.

FAQ

What is the docker-context command used for?

docker context manages Docker contexts, which are configuration profiles that store connection information for different Docker engines. Contexts enable seamless switching between local, remote, and cloud-based Docker hosts without manually reconfiguring connection settings. Each context contains endpoint information, TLS certificates, and other metadata needed to communicate with a Docker daemon. This is particularly useful for developers and operators who work with multiple Docker environments, such as local development, staging servers, and production clusters. The default context named "default" connects to the local Docker daemon via Unix socket. Additional contexts can be created to connect to remote Docker hosts over SSH, TCP, or other protocols.

How do I run a basic docker-context example?

Run `docker context ls` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more docker-context examples?

This page includes 6 examples for docker-context, plus related commands for nearby Linux tasks.