Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d9bdd2

Browse files
Merge pull request docker#679 from londoncalling/d4win-powershell-tab-completion
d4win added how to set up docker tab completion in Powershell
2 parents 0e65544 + 43822ab commit 3d9bdd2

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
871 KB
Loading

docker-for-windows/index.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,44 @@ The next few steps take you through some examples. These are just suggestions fo
284284

285285
**Want more example applications?** - For more example walkthroughs that include setting up services and databases with Docker Compose, see [Example Applications](examples.md).
286286

287+
## Set up tab completion in PowerShell
288+
289+
If you would like to have handy tab completion for Docker commands, you can install the <a href="https://github.com/samneirinck/posh-docker">posh-docker</a> PowerShell Module as follows.
290+
291+
1. Start an "elevated" PowerShell (i.e., run it as administrator).
292+
293+
To do this, search for PowerShell, right-click, and choose **Run as administrator**.<br>
294+
295+
![Run PowerShell as administrator](images/PowerShell-as-admin.png)
296+
<br><br>
297+
When asked if you want to allow this app to make changes to your device, click **Yes**.
298+
299+
2. Set the [script execution policy](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.security/set-executionpolicy) to allow downloaded scripts signed by trusted publishers to run on your computer. To do so, type this at the PowerShell prompt.
300+
<br>
301+
`Set-ExecutionPolicy RemoteSigned`
302+
<br>
303+
To check that the policy is set properly, run `get-executionpolicy`, which should return `RemoteSigned`.
304+
<br>
305+
3. To enable auto-completion of commands for the current PowerShell only, type:
306+
307+
`Import-Module posh-docker`
308+
309+
4. To make tab completion persistent across all PowerShell sessions, add the command to a `$PROFILE` by typing these commands at the PowerShell prompt.
310+
311+
Install-Module -Scope CurrentUser posh-docker -Force
312+
Add-Content $PROFILE "`nImport-Module posh-docker"
313+
314+
This creates a `$PROFILE` if one does not already exist, and adds this line into the file:
315+
316+
`Import-Module posh-docker`
317+
318+
<br>
319+
To check that the file was properly created, or simply edit it manually, type this in PowerShell:
320+
321+
`Notepad $PROFILE`
322+
323+
Now, when you press tab after typing the first few letters, Docker commands such as `start`, `stop`, `run`, and their options, along with container and image names should now auto-complete.
324+
287325
## Docker Settings
288326

289327
When Docker is running, the Docker whale is displayed in the system tray. If it is hidden, click the up arrow in the tray to show it.

0 commit comments

Comments
 (0)