Docker
/Advanced
Docker Contexts
Definition
A CLI feature that allows a single Docker Client on your local machine to connect to, manage, and seamlessly switch between multiple different Docker Engines (e.g., a local daemon and a remote AWS daemon).
Explain Like I'm New
A remote control with multiple profiles. Profile 1 controls your laptop's Docker. Profile 2 securely connects over SSH and controls the Docker Engine on your production server in London.
Real World Example
You type `docker context use production`. Now, when you type `docker ps` on your laptop, it doesn't show your local containers; it shows the containers running on the remote cloud server. You type `docker context use default` to switch back to your laptop.
Common Use Cases
- •Managing remote servers
- •Multi-environment workflows
Interview Questions
basic
- Can Docker Contexts securely connect to a remote server using SSH?
intermediate
- Why are Contexts considered safer than modifying the `DOCKER_HOST` environment variable?