Verify the imported context
In the previous steps, we created, exported, and then imported a Docker context using two different methods: from a file and from standard input. In this final step, we will verify that the imported context is functional and can be used to interact with the Docker daemon.
First, let's list the available contexts to confirm that both my-context-from-file
and my-context-from-stdin
are present.
docker context ls
You should see both contexts listed in the output.
Now, let's switch to the context we imported from standard input, my-context-from-stdin
.
docker context use my-context-from-stdin
This command sets the current Docker context to my-context-from-stdin
. Any subsequent Docker commands will now use this context to connect to the Docker daemon.
To verify that the context is working correctly, let's run a simple Docker command, such as listing the running containers. Since we are connecting to the local Docker daemon, this command should show the same output as running docker ps
without specifying a context.
docker ps
If the context is configured correctly, this command should execute successfully and display the list of running containers (if any).
Finally, let's switch back to the default context.
docker context use default
This command switches the current Docker context back to the default local daemon.