Browse code

add DSC article

Docker-DCO-1.1-Signed-off-by: Andrew Weiss <andrew.weiss@outlook.com> (github: anweiss)

Andrew Weiss authored on 2014/07/01 04:35:30
Showing 2 changed files
... ...
@@ -87,6 +87,7 @@ pages:
87 87
 - ['articles/cfengine_process_management.md', 'Articles', 'Process management with CFEngine']
88 88
 - ['articles/puppet.md', 'Articles', 'Using Puppet']
89 89
 - ['articles/chef.md', 'Articles', 'Using Chef']
90
+- ['articles/dsc.md', 'Articles', 'Using PowerShell DSC']
90 91
 - ['articles/ambassador_pattern_linking.md', 'Articles', 'Cross-Host linking using Ambassador Containers']
91 92
 - ['articles/runmetrics.md', 'Articles', 'Runtime metrics']
92 93
 - ['articles/baseimages.md', 'Articles', 'Creating a Base Image']
93 94
new file mode 100644
... ...
@@ -0,0 +1,117 @@
0
+page_title: PowerShell DSC Usage
1
+page_description: Using DSC to configure a new Docker host
2
+page_keywords: powershell, dsc, installation, usage, docker, documentation
3
+
4
+# Using PowerShell DSC
5
+
6
+Windows PowerShell Desired State Configuration (DSC) is a configuration
7
+management tool that extends the existing functionality of Windows PowerShell.
8
+DSC uses a declarative syntax to define the state in which a target should be
9
+configured. More information about PowerShell DSC can be found at
10
+http://technet.microsoft.com/en-us/library/dn249912.aspx.
11
+
12
+## Requirements
13
+
14
+To use this guide you'll need a Windows host with PowerShell v4.0 or newer.
15
+
16
+The included DSC configuration script also uses the official PPA so
17
+only an Ubuntu target is supported. The Ubuntu target must already have the
18
+required OMI Server and PowerShell DSC for Linux providers installed. More
19
+information can be found at https://github.com/MSFTOSSMgmt/WPSDSCLinux. The
20
+source repository listed below also includes PowerShell DSC for Linux
21
+installation and init scripts along with more detailed installation information.
22
+
23
+## Installation
24
+
25
+The DSC configuration example source is available in the following repository:
26
+https://github.com/anweiss/DockerClientDSC. It can be cloned with:
27
+
28
+    $ git clone https://github.com/anweiss/DockerClientDSC.git
29
+
30
+## Usage
31
+
32
+The DSC configuration utilizes a set of shell scripts to determine whether or
33
+not the specified Docker components are configured on the target node(s). The
34
+source repository also includes a script (`RunDockerClientConfig.ps1`) that can
35
+be used to establish the required CIM session(s) and execute the
36
+`Set-DscConfiguration` cmdlet.
37
+
38
+More detailed usage information can be found at
39
+https://github.com/anweiss/DockerClientDSC.
40
+
41
+### Run Configuration
42
+The Docker installation configuration is equivalent to running:
43
+
44
+```
45
+apt-get install docker.io
46
+ln -sf /usr/bin/docker.io /usr/local/bin/docker
47
+sed -i '$acomplete -F _docker docker' /etc/bash_completion.d/docker.io
48
+```
49
+
50
+Ensure that your current working directory is set to the `DockerClientDSC`
51
+source and load the DockerClient configuration into the current PowerShell
52
+session
53
+
54
+```powershell
55
+. .\DockerClient.ps1
56
+```
57
+
58
+Generate the required DSC configuration .mof file for the targeted node
59
+
60
+```powershell
61
+DockerClient -Hostname "myhost"
62
+```
63
+
64
+A sample DSC configuration data file has also been included and can be modified
65
+and used in conjunction with or in place of the `Hostname` parameter:
66
+
67
+```powershell
68
+DockerClient -ConfigurationData .\DockerConfigData.psd1
69
+```
70
+
71
+Start the configuration application process on the targeted node
72
+
73
+```powershell
74
+.\RunDockerClientConfig.ps1 -Hostname "myhost"
75
+```
76
+
77
+The `RunDockerClientConfig.ps1` script can also parse a DSC configuration data
78
+file and execute configurations against multiple nodes as such:
79
+
80
+```powershell
81
+.\RunDockerClientConfig.ps1 -ConfigurationData .\DockerConfigData.psd1
82
+```
83
+
84
+### Images
85
+Image configuration is equivalent to running: `docker pull [image]`.
86
+
87
+Using the same Run Configuration steps defined above, execute `DockerClient`
88
+with the `Image` parameter:
89
+
90
+```powershell
91
+DockerClient -Hostname "myhost" -Image node
92
+```
93
+
94
+The configuration process can be initiated as before:
95
+
96
+```powershell
97
+.\RunDockerClientConfig.ps1 -Hostname "myhost"
98
+```
99
+
100
+### Containers
101
+Container configuration is equivalent to running:
102
+`docker run -d --name="[containername]" [image] '[command]'`.
103
+
104
+Using the same Run Configuration steps defined above, execute `DockerClient`
105
+with the `Image`, `ContainerName`, and `Command` parameters:
106
+
107
+```powershell
108
+DockerClient -Hostname "myhost" -Image node -ContainerName "helloworld" `
109
+-Command 'echo "Hello World!"'
110
+```
111
+
112
+The configuration process can be initiated as before:
113
+
114
+```powershell
115
+.\RunDockerClientConfig.ps1 -Hostname "myhost"
116
+```