github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/context_show.md (about) 1 # context show 2 3 <!---MARKER_GEN_START--> 4 Print the name of the current context 5 6 7 <!---MARKER_GEN_END--> 8 9 ## Description 10 11 Print the name of the current context, possibly set by `DOCKER_CONTEXT` environment 12 variable or `--context` global option. 13 14 ## Examples 15 16 ### Print the current context 17 18 The following example prints the currently used [`docker context`](context.md): 19 20 ```console 21 $ docker context show' 22 default 23 ``` 24 25 As an example, this output can be used to dynamically change your shell prompt 26 to indicate your active context. The example below illustrates how this output 27 could be used when using Bash as your shell. 28 29 Declare a function to obtain the current context in your `~/.bashrc`, and set 30 this command as your `PROMPT_COMMAND` 31 32 ```console 33 function docker_context_prompt() { 34 PS1="context: $(docker context show)> " 35 } 36 37 PROMPT_COMMAND=docker_context_prompt 38 ``` 39 40 After reloading the `~/.bashrc`, the prompt now shows the currently selected 41 `docker context`: 42 43 ```console 44 $ source ~/.bashrc 45 context: default> docker context create --docker host=unix:///var/run/docker.sock my-context 46 my-context 47 Successfully created context "my-context" 48 context: default> docker context use my-context 49 my-context 50 Current context is now "my-context" 51 context: my-context> docker context use default 52 default 53 Current context is now "default" 54 context: default> 55 ```