-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Description
Docker CLI 19.03 adds new context management features to quickly switch between Docker engines/clusters. While it is really handy, I'm finding it difficult to work with across terminal sessions.
I regularly have several Terminal windows open, connected to several separate Docker engines by setting environment variables like DOCKER_HOST, DOCKER_CONFIG, and DOCKER_TLS_VERIFY. When set in separate terminal sessions, they can independently talk to different engines.
With contexts, selecting a context with docker context use CONTEXT affects all terminal sessions. The -c, --context option can be used to override the context to use, but then that has to be specified with every command.
I would like an environment variable corresponding to the -c, --context option to set the context to use in a terminal session.
Steps to reproduce the issue:
Assume that there are two Docker contexts available named default and remote, and that the current context is default.
- Open two terminal sessions.
- In the first terminal session, run
docker context use remote. - In the second terminal session, attempt to interact with the local Docker engine.
Describe the results you received:
Invoking docker context use … sets the default context everywhere. There is not an easy way to use different contexts in different terminal sessions.
Describe the results you expected:
An environment variable such as DOCKER_CONTEXT that corresponds to the -c, --context CLI option to override the context to use.
Additional information you deem important (e.g. issue happens only occasionally):
Aliasing docker can be used as a way to set the context without affecting things system-wide.
alias docker="docker --context remote"
Output of docker version:
Client: Docker Engine - Community
Version: 19.03.0-beta3
API version: 1.40
Go version: go1.12.4
Git commit: c55e026
Built: Thu Apr 25 19:05:38 2019
OS/Arch: darwin/amd64
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 19.03.0-beta3
API version: 1.40 (minimum version 1.12)
Go version: go1.12.4
Git commit: c55e026
Built: Thu Apr 25 19:13:00 2019
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: v1.2.6
GitCommit: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc:
Version: 1.0.0-rc7+dev
GitCommit: 029124da7af7360afa781a0234d1b083550f797c
docker-init:
Version: 0.18.0
GitCommit: fec3683
Output of docker info:
Client:
Debug Mode: false
Plugins:
app: Docker Application (Docker Inc., v0.8.0-beta1)
buildx: Build with BuildKit (Docker Inc., v0.2.0-tp)
Server:
Containers: 14
Running: 11
Paused: 0
Stopped: 3
Images: 124
Server Version: 19.03.0-beta3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: active
NodeID: ilntgb4sbycucyl3iiva1wk3p
Is Manager: true
ClusterID: wsz99afbhy169obu69h1eq7z0
Managers: 1
Nodes: 1
Default Address Pool: 10.0.0.0/8
SubnetSize: 24
Data Path Port: 4789
Orchestration:
Task History Retention Limit: 5
Raft:
Snapshot Interval: 10000
Number of Old Snapshots to Retain: 0
Heartbeat Tick: 1
Election Tick: 10
Dispatcher:
Heartbeat Period: 5 seconds
CA Configuration:
Expiry Duration: 3 months
Force Rotate: 0
Autolock Managers: false
Root Rotation In Progress: false
Node Address: 192.168.65.3
Manager Addresses:
192.168.65.3:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb
runc version: 029124da7af7360afa781a0234d1b083550f797c
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 6
Total Memory: 11.71GiB
Name: docker-desktop
ID: b5307ed3-4dc8-4eb4-b931-138544ef581f
Docker Root Dir: /var/lib/docker
Debug Mode: true
File Descriptors: 103
Goroutines: 262
System Time: 2019-05-21T21:26:28.9230849Z
EventsListeners: 7
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine
Additional environment details (AWS, VirtualBox, physical, etc.):
Context management is new in CLI 19.03.