New Docker Feature: Change Your Context!

#15・
4.67K

subscribers

29

issues

Subscribe to our newsletter

By subscribing, you agree with Revue’s Terms of Service and Privacy Policy and understand that Vital DevOps: Improving Your Container DevOps Skills will receive your email address.

Bret Fisher
Bret Fisher
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,
–Bret
Weekly YouTube Live: bretfisher.com/youtube
Course Coupons: bretfisher.com/courses
Did you enjoy this issue? Yes No
Bret Fisher
Bret Fisher @bretfisher

Commentary on tools and techniques I find interesting around Docker, Kubernetes, Cloud Native DevOps, and DevSecOps.

In order to unsubscribe, click here.
If you were forwarded this newsletter and you like it, you can subscribe here.
Created with Revue by Twitter.
Bret Fisher, Virginia Beach, Virginia, USA