docker context — Manage multiple clusters

Sujay Pillai
May 22 · 4 min read

The major announcement during DockerCon 2019 was about “Docker Enterprise 3.0” which delivers new desktop capabilities, advanced development productivity tools, a simplified and secure Kubernetes stack, and a managed service option to make Docker Enterprise 3.0 the platform for digital transformation. I did signup for the beta access and got it last week. This beta consists of :

  • Docker Desktop Enterprise 2.0.0.4-ent
  • Universal Control Plane 3.2
  • Docker Trusted Registry 2.7
  • Docker Engine — Enterprise 19.03.0-beta4

Docker Enterprise 3.0 is available for Beta trial — register here.


The beta access only supports limited subset of operating systems — RHEL 7.6, Ubuntu [16.04 & 18.04] and Windows Server 2019. On my mac I had to uninstall my Docker Desktop Community edition to replace it with Docker Desktop Enterprise (also has the Docker Application which includes a set of tooling that enables end-to-end application consistency and scalability from developers to operators).

Then on a virtual box I did setup Ubuntu 18.04 on which the UCP was installed (don’t worry about the installation step your beta access will provide you a good documentation around the same )—

UCP allows you to securely manage your cluster in a visual way, from your browser by using RBAC. You may also access UCP from the CLI with the help from client bundle. A client bundle contains a private and public key pair that authorizes your requests in UCP. It also contains utility scripts you can use to configure your Docker and kubectl client tools to talk to your UCP deployment. Download the client bundle by navigating to “My Profile > Client Bundles > New Client Bundle”.

Navigate to the directory where you downloaded the user bundle, and extract the zip file into a directory. It contains a utility script that updates the environment variables DOCKER_HOST to make your client tools communicate with your UCP deployment, and the DOCKER_CERT_PATH environment variable to use the client certificates that are included in the client bundle you downloaded.

That’s all fine … what’s new in that?

The ucp-bundle-admin.dockercontext file.

As part of Docker 19.03.0-beta release docker context command were added for fast context switching.

Lets use the above file — ucp-bundle-admin.dockercontext to create a new context (pointing to my local UCP installation) as shown below —

docker context import localucp ucp-bundle-admin.dockercontext

Now all the docker commands you execute on your cli will be run against the DOCKER_HOST as configured in your active context.

e.g.docker node ls output shows the current active node in my cluster.

Output of `docker node ls` command after setting the context to my local UCP installation

e.g.docker service ls output shows all the default UCP services running after a fresh installation.

Output of `docker service ls` command after setting the context to my local UCP installation

docker context inspect localucp


You may explicitly pass the required context against which the command should be executed —

Current context is set to localucp while the command is executed against default context

Please do read all the comments in the PR involved for this feature here which would give you more insights about `docker context` command.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade