-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
- This is a bug report
- This is a feature request
- I searched existing issues before opening this one
Expected behavior
Return current used docker context faster
Actual behavior
while using a remote docker host context through a VPN or over the internet, the listing and inspecting of the contexts is very slow
$ time docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
bb-dev * BB Dev Environment ssh://deploy@192.168.213.214 swarm
default Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
real 0m2.547s
user 0m0.020s
sys 0m0.015s
If using the default (local) docker context , everything seems to be ok
$ docker context use default
Current context is now "default"
$ time docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
bb-dev BB Dev Environment ssh://deploy@192.168.213.214 swarm
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
real 0m0.026s
user 0m0.024s
sys 0m0.010s
Steps to reproduce the behavior
Output of docker version:
lient: Docker Engine - Community
Version: 19.03.11
API version: 1.40
Go version: go1.13.10
Git commit: 42e35e61f3
Built: Mon Jun 1 09:12:34 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.11
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 42e35e61f3
Built: Mon Jun 1 09:11:07 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Output of docker info:
Client:
Debug Mode: false
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 37
Server Version: 19.03.11
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: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-37-generic
Operating System: Ubuntu 20.04 LTS
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 15.56GiB
Name: aduzsardi-nix
ID: V6CN:HNWD:PENV:MYG3:2ORG:SYRC:P6LD:HJNM:P3GS:OZ3K:7VTR:6QWV
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
gitlab.bigbrother.lokaal:5005
127.0.0.0/8
Live Restore Enabled: false
WARNING: No swap limit support
Additional environment details (AWS, VirtualBox, physical, etc.)
I'm connecting to remote docker or docker swarm hosts trough VPNs from home to office network
I want to set my bash prompt to show the docker context currently in use so i know where i am at all times , but the time it takes to return my prompt every time i press the return key on the keyboard takes about ~3s of so it's not usable
The script i was using
$ cat /etc/profile.d/docker_prompt.sh
#!/bin/bash
_get_docker_ctx()
{
# Get current context
if type docker &>/dev/null; then
CONTEXT=$(docker context ls | grep -F '*' | awk '{ print $1}')
fi
}
__docker_ps1()
{
_get_docker_ctx
if [ -n "$CONTEXT" ]; then
echo "[dctx: ${CONTEXT}] - "
fi
}
__colored_docker_ps1()
{
_get_docker_ctx
if [ -n "$CONTEXT" ]; then
echo -e "\e[1m\e[37m[\e[92mdctx: \e[36m${CONTEXT}\e[37m] - \e[0m"
fi
}And PS1 prompt
export PS1='$(__colored_docker_ps1)\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$'
Proposal
It would be nice if we could read the currently used context from a file or config , so every time you run docker context use ... the config would be updated with the "current-context: something" like kubectl does