View profile

New Docker Feature: Change Your Context!

Hey container champs! I'm still traveling in Europe for another week, and it's been great seeing stud
New Docker Feature: Change Your Context!
By Bret Fisher • Issue #15 • View online
Hey container champs! I’m still traveling in Europe for another week, and it’s been great seeing students at Udemy LIVE and GOTO Conf (and students reaching out on Twitter for meeting up in Berlin!).
This week let’s revisit Docker context.

docker context was added in 19.03, let's start using it!
docker context was added in 19.03, let's start using it!
Watch Demos of Docker Context From My YouTube Live Show
Use Docker Context To Control Many Servers
Keeping up with the latest updates in the 19.03 release, we covered a topic called “fast context switching”. A context is the configuration in which we interact with Docker, Swarm, or Kubernetes on a specific server. Context switching allows you to quickly change between multiple Docker endpoints without having to go in and set/unset environment variables.
Docker Context info from Captain Sujay
Multiple Endpoints Can Be Saved as Contexts!
By saving a remote endpoint as a context, you can quickly shift between talking to multiple different clusters or individual nodes in a single line command. For instance, if you have a test cluster, you can save the remote endpoint in a context called “test” and then run docker -c test ps from your local CLI. This will run the ps command on the test cluster endpoint, bypassing the need to change environment variables, or SSH into the test server. To immediately compare your test cluster with a prod cluster, all you would need to do is create another context for production, and you can switch to the context with the docker context use command, or just switch for a one off command like we did before using the -c option, with docker -c prod <docker command>. Also, these contexts can talk to more than just one type of cluster. In the blog post below, Ajeet has 3 contexts saved of a Swarm cluster, a Kubernetes cluster, and a play-with-docker cluster.
Docker Docs: Context Create
Contexts + SSH = Safe and Happy Docker!
Another really cool feature that was demonstrated by Marcos Nils in my 19.03 release party was that we can save these contexts so that we can interact with a remote endpoint over SSH instead of TCP+TLS. We could run the command docker context create ssh –docker “host=ssh://root@x.x.x.x”, or if you add a friendly name to your server in the “.ssh/config” file, you can substitute the IP for the friendly name there too!
Thanks for reading,
Weekly YouTube Live:
Course Coupons:
Did you enjoy this issue?
Bret Fisher

Frequent updates on my projects, videos, and opinions focused on the container ecosystem, including Docker, Kubernetes, Docker Swarm, CI/CD, and container DevOps.

If you don't want these updates anymore, please unsubscribe here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Powered by Revue
Bret Fisher, Virginia Beach, Virginia, USA